﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ChartTools;
using System.Data.Entity;
namespace BenefitHelper.Tools
{
    /// <summary>
    /// 交易汇总
    /// </summary>
    public class ChartAtManager
    {
        /// <summary>
        /// 首页上面的收益按小时分布曲线
        /// </summary>
        /// <param name="tradeHistoryId"></param>
        /// <param name="operatorid"></param>
        /// <returns></returns>
        public static string GetTodayBenefitString(int tradeHistoryId, int operatorid, DB.DBManager db)
        {
            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "平仓盈亏";
            data.LineName = "累计平仓盈亏";


            View.OperatorDayTradeInfo info = new View.OperatorDayTradeInfo();
            info = info.GetOperatorDayTradeInfo(tradeHistoryId, operatorid, "profit", db);



            List<double> coldatas = new List<double>();
            List<View.OperatorDayTradeInfoData> datas = info.Datas;
            foreach (View.OperatorDayTradeInfoData a in datas)
            {
                coldatas.Add(a.SumValue);
            }

            data.ColDatas = coldatas;
            List<double> coldatas2 = new List<double>();

            for (int i = 0; i < coldatas.Count; i++)
            {
                double temp = 0f;
                for (int j = 0; j <= i; j++)
                {
                    temp += coldatas[j];
                }
                coldatas2.Add(temp);

            }
            data.LineDatas = coldatas2;
            List<string> names = new List<string>();
            names.Add("9:30");
            names.Add("10:00");
            names.Add("10:30");
            names.Add("11:00");
            names.Add("13:30");
            names.Add("14:00");
            names.Add("14:30");
            names.Add("15:00");
            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "TodayBenefit", "showflash", "收益示意图");
            return d3.ToString();
        }
        public static string GetTodayBenefitString2()
        {
            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "亏损次数";
            data.LineName = "亏损金额";
            List<double> coldatas = new List<double>();
            Random rand = new Random();
            for (int i = 0; i < 9; i++)
            {
                int a = rand.Next(1, 10);
                if (a > 3)
                {
                    coldatas.Add(rand.Next(200, 1000));
                }
                else
                {
                    coldatas.Add(0 - rand.Next(200, 1000));
                }

            }
            data.ColDatas = coldatas;
            List<double> coldatas2 = new List<double>();
            for (int i = 0; i < 9; i++)
            {
                int a = rand.Next(1, 10);
                if (a > 3)
                {
                    coldatas2.Add(rand.Next(200, 1000));
                }
                else
                {
                    coldatas2.Add(0 - rand.Next(200, 1000));
                }

            }
            data.LineDatas = coldatas2;
            List<string> names = new List<string>();
            names.Add("9:00");
            names.Add("9:30");
            names.Add("10:00");
            names.Add("10:30");
            names.Add("11:00");
            names.Add("13:30");
            names.Add("14:00");
            names.Add("14:30");
            names.Add("15:00");
            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "TodayBenefit2", "showflash2", "亏损意图");
            return d3.ToString();
        }
        public static string GetTodayBenefitString3()
        {
            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "盈利次数";
            data.LineName = "盈利金额";
            List<double> coldatas = new List<double>();
            Random rand = new Random();
            for (int i = 0; i < 9; i++)
            {
                int a = rand.Next(1, 10);
                if (a > 3)
                {
                    coldatas.Add(rand.Next(200, 1000));
                }
                else
                {
                    coldatas.Add(0 - rand.Next(200, 1000));
                }

            }
            data.ColDatas = coldatas;
            List<double> coldatas2 = new List<double>();
            for (int i = 0; i < 9; i++)
            {
                int a = rand.Next(1, 10);
                if (a > 3)
                {
                    coldatas2.Add(rand.Next(200, 1000));
                }
                else
                {
                    coldatas2.Add(0 - rand.Next(200, 1000));
                }

            }
            data.LineDatas = coldatas2;
            List<string> names = new List<string>();
            names.Add("9:00");
            names.Add("9:30");
            names.Add("10:00");
            names.Add("10:30");
            names.Add("11:00");
            names.Add("13:30");
            names.Add("14:00");
            names.Add("14:30");
            names.Add("15:00");
            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "TodayBenefit3", "showflash2", "连续盈利示意图");
            return d3.ToString();
        }

        public static string GetMonthBenefitString(List<View.OperatorDayChange> datas)
        {
            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "平仓盈亏";
            data.LineName = "累计平仓盈亏";
            List<double> coldatas = new List<double>();
            Random rand = new Random();
            List<string> names = new List<string>();
            for (int i = 0; i < datas.Count; i++)
            {
                coldatas.Add(datas[i].Profit);
                names.Add(datas[i].TradeHistory.DPdate.ToString());
            }
            data.ColDatas = coldatas;
            List<double> coldatas2 = new List<double>();
            double sum = 0;
            for (int i = 0; i < datas.Count; i++)
            {
                sum += datas[i].Profit;
                coldatas.Add(sum);
            }
            data.LineDatas = coldatas2;


            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "MonthBenefit", "showflash2", "月分析图");
            return d3.ToString();
        }

        public static string GetYearBenefitString(List<View.OperatorMonthSum> datas)
        {
            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "平仓盈亏";
            data.LineName = "累计平仓盈亏";
            List<double> coldatas = new List<double>();
            Random rand = new Random();
            List<string> names = new List<string>();
            for (int i = 0; i < datas.Count; i++)
            {
                coldatas.Add(datas[i].Profit);
                names.Add(datas[i].Month.ToString());
            }
            data.ColDatas = coldatas;
            List<double> coldatas2 = new List<double>();
            double sum = 0;
            for (int i = 0; i < datas.Count; i++)
            {
                sum += datas[i].Profit;
                coldatas.Add(sum);
            }
            data.LineDatas = coldatas2;


            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "MonthBenefit", "showflash2", "年分析图");
            return d3.ToString();
        }

        public static string GetMonthBenefitString2()
        {
            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "平仓盈亏";
            data.LineName = "累计平仓盈亏";
            List<double> coldatas = new List<double>();
            Random rand = new Random();
            for (int i = 0; i < 16; i++)
            {
                int a = rand.Next(1, 10);
                if (a > 3)
                {
                    coldatas.Add(rand.Next(200, 1000));
                }
                else
                {
                    coldatas.Add(0 - rand.Next(200, 1000));
                }

            }
            data.ColDatas = coldatas;
            List<double> coldatas2 = new List<double>();
            for (int i = 0; i < 16; i++)
            {
                int a = rand.Next(1, 10);
                if (a > 3)
                {
                    coldatas2.Add(rand.Next(200, 1000));
                }
                else
                {
                    coldatas2.Add(0 - rand.Next(200, 1000));
                }

            }
            data.LineDatas = coldatas2;
            List<string> names = new List<string>();
            names.Add("1");
            names.Add("2");
            names.Add("3");
            names.Add("4");
            names.Add("5");
            names.Add("8");
            names.Add("9");
            names.Add("10");
            names.Add("11");
            names.Add("12");
            names.Add("15");
            names.Add("16");
            names.Add("17");
            names.Add("18");
            names.Add("19");
            names.Add("22");
            names.Add("23");
            names.Add("24");
            names.Add("25");
            names.Add("26");
            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "GetMonthBenefitString2", "showflash", "月分析图");
            return d3.ToString();
        }
        public static string GetMonthFeeString()
        {
            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "手续费";
            data.LineName = "累计手续费";
            List<double> coldatas = new List<double>();
            Random rand = new Random();
            for (int i = 0; i < 20; i++)
            {
                int a = rand.Next(1, 10);
                if (a > 3)
                {
                    coldatas.Add(rand.Next(200, 1000));
                }
                else
                {
                    coldatas.Add(0 - rand.Next(200, 1000));
                }

            }
            data.ColDatas = coldatas;
            List<double> coldatas2 = new List<double>();
            for (int i = 0; i < 20; i++)
            {
                int a = rand.Next(1, 10);
                if (a > 3)
                {
                    coldatas2.Add(rand.Next(200, 1000));
                }
                else
                {
                    coldatas2.Add(0 - rand.Next(200, 1000));
                }

            }
            data.LineDatas = coldatas2;
            List<string> names = new List<string>();
            names.Add("1");
            names.Add("2");
            names.Add("3");
            names.Add("4");
            names.Add("5");
            names.Add("8");
            names.Add("9");
            names.Add("10");
            names.Add("11");
            names.Add("12");
            names.Add("15");
            names.Add("16");
            names.Add("17");
            names.Add("18");
            names.Add("19");
            names.Add("22");
            names.Add("23");
            names.Add("24");
            names.Add("25");
            names.Add("26");
            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "MonthFee", "showflash2", "月分析图");
            return d3.ToString();
        }

        public static string GetMonthBillcountString()
        {
            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "交易笔数";
            data.LineName = "累计交易笔数";
            List<double> coldatas = new List<double>();
            Random rand = new Random();
            for (int i = 0; i < 20; i++)
            {
                int a = rand.Next(1, 10);
                if (a > 3)
                {
                    coldatas.Add(rand.Next(200, 1000));
                }
                else
                {
                    coldatas.Add(0 - rand.Next(200, 1000));
                }

            }
            data.ColDatas = coldatas;
            List<double> coldatas2 = new List<double>();
            for (int i = 0; i < 20; i++)
            {
                int a = rand.Next(1, 10);
                if (a > 3)
                {
                    coldatas.Add(rand.Next(200, 1000));
                }
                else
                {
                    coldatas.Add(0 - rand.Next(200, 1000));
                }

            }
            data.LineDatas = coldatas2;
            List<string> names = new List<string>();
            names.Add("1");
            names.Add("2");
            names.Add("3");
            names.Add("4");
            names.Add("5");
            names.Add("8");
            names.Add("9");
            names.Add("10");
            names.Add("11");
            names.Add("12");
            names.Add("15");
            names.Add("16");
            names.Add("17");
            names.Add("18");
            names.Add("19");
            names.Add("22");
            names.Add("23");
            names.Add("24");
            names.Add("25");
            names.Add("26");
            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "MonthBillcount", "showflash2", "月分析图");
            return d3.ToString();
        }

        public static string GetMonthDaycountString()
        {
            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "总盈利";
            data.LineName = "累计总盈利";
            List<double> coldatas = new List<double>();
            Random rand = new Random();
            for (int i = 0; i < 20; i++)
            {
                int a = rand.Next(1, 10);
                if (a > 3)
                {
                    coldatas.Add(rand.Next(200, 1000));
                }
                else
                {
                    coldatas.Add(0 - rand.Next(200, 1000));
                }

            }
            data.ColDatas = coldatas;
            List<double> coldatas2 = new List<double>();
            for (int i = 0; i < 20; i++)
            {
                int a = rand.Next(1, 10);
                if (a > 3)
                {
                    coldatas2.Add(rand.Next(200, 1000));
                }
                else
                {
                    coldatas2.Add(0 - rand.Next(200, 1000));
                }

            }
            data.LineDatas = coldatas2;
            List<string> names = new List<string>();
            names.Add("1");
            names.Add("2");
            names.Add("3");
            names.Add("4");
            names.Add("5");
            names.Add("8");
            names.Add("9");
            names.Add("10");
            names.Add("11");
            names.Add("12");
            names.Add("15");
            names.Add("16");
            names.Add("17");
            names.Add("18");
            names.Add("19");
            names.Add("22");
            names.Add("23");
            names.Add("24");
            names.Add("25");
            names.Add("26");
            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "MonthDaycount", "showflash2", "月分析图");
            return d3.ToString();
        }

        public static string GetMonthWincountString()
        {
            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "盈利次数";
            data.LineName = "累计盈利次数";
            List<double> coldatas = new List<double>();
            Random rand = new Random();
            for (int i = 0; i < 20; i++)
            {
                int a = rand.Next(1, 10);
                if (a > 3)
                {
                    coldatas.Add(rand.Next(200, 1000));
                }
                else
                {
                    coldatas.Add(0 - rand.Next(200, 1000));
                }

            }
            data.ColDatas = coldatas;
            List<double> coldatas2 = new List<double>();
            for (int i = 0; i < 20; i++)
            {
                int a = rand.Next(1, 10);
                if (a > 3)
                {
                    coldatas2.Add(rand.Next(200, 1000));
                }
                else
                {
                    coldatas2.Add(0 - rand.Next(200, 1000));
                }

            }
            data.LineDatas = coldatas2;
            List<string> names = new List<string>();
            names.Add("1");
            names.Add("2");
            names.Add("3");
            names.Add("4");
            names.Add("5");
            names.Add("8");
            names.Add("9");
            names.Add("10");
            names.Add("11");
            names.Add("12");
            names.Add("15");
            names.Add("16");
            names.Add("17");
            names.Add("18");
            names.Add("19");
            names.Add("22");
            names.Add("23");
            names.Add("24");
            names.Add("25");
            names.Add("26");
            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "MonthWincount", "showflash2", "月分析图");
            return d3.ToString();
        }

        public static string GetMonthLosecountString()
        {
            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "亏损次数";
            data.LineName = "累计亏损次数";
            List<double> coldatas = new List<double>();
            Random rand = new Random();
            for (int i = 0; i < 20; i++)
            {
                int a = rand.Next(1, 10);
                if (a > 3)
                {
                    coldatas.Add(rand.Next(200, 1000));
                }
                else
                {
                    coldatas.Add(0 - rand.Next(200, 1000));
                }

            }
            data.ColDatas = coldatas;
            List<double> coldatas2 = new List<double>();

            for (int i = 0; i < 16; i++)
            {
                int a = rand.Next(1, 10);
                if (a > 3)
                {
                    coldatas2.Add(rand.Next(200, 1000));
                }
                else
                {
                    coldatas2.Add(0 - rand.Next(200, 1000));
                }

            }
            data.LineDatas = coldatas2;
            List<string> names = new List<string>();
            names.Add("1");
            names.Add("2");
            names.Add("3");
            names.Add("4");
            names.Add("5");
            names.Add("8");
            names.Add("9");
            names.Add("10");
            names.Add("11");
            names.Add("12");
            names.Add("15");
            names.Add("16");
            names.Add("17");
            names.Add("18");
            names.Add("19");
            names.Add("22");
            names.Add("23");
            names.Add("24");
            names.Add("25");
            names.Add("26");
            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "MonthLosecount", "showflash2", "月分析图");
            return d3.ToString();
        }

        //public static string ShowDetails1()
        //{
        //    List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
        //    ChartTools.Pie3DData data = new ChartTools.Pie3DData();
        //    data.Label = "多头";
        //    data.IsSelected = true;
        //    data.Value = 948;
        //    datas.Add(data);
        //    data = new ChartTools.Pie3DData();
        //    data.Label = "空头";
        //    data.IsSelected = false;
        //    data.Value = 584;
        //    datas.Add(data);
        //    ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "showDetails1", "showDetailsContent1");
        //    return pie3d.ToString();
        //}

        //public static string ShowDetails2()
        //{
        //    List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
        //    ChartTools.Pie3DData data = new ChartTools.Pie3DData();
        //    data.Label = "多头";
        //    data.IsSelected = true;
        //    data.Value = 9248;
        //    datas.Add(data);
        //    data = new ChartTools.Pie3DData();
        //    data.Label = "空头";
        //    data.IsSelected = false;
        //    data.Value = 584;
        //    datas.Add(data);
        //    ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "showDetails2", "showDetailsContent2");
        //    return pie3d.ToString();
        //}

        //public static string ShowDetails3()
        //{
        //    List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
        //    ChartTools.Pie3DData data = new ChartTools.Pie3DData();
        //    data.Label = "多头";
        //    data.IsSelected = true;
        //    data.Value = 948;
        //    datas.Add(data);
        //    data = new ChartTools.Pie3DData();
        //    data.Label = "空头";
        //    data.IsSelected = false;
        //    data.Value = 3584;
        //    datas.Add(data);
        //    ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "showDetails3", "showDetailsContent3");
        //    return pie3d.ToString();
        //}

        //public static string ShowDetails4()
        //{
        //    List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
        //    ChartTools.Pie3DData data = new ChartTools.Pie3DData();
        //    data.Label = "多头";
        //    data.IsSelected = true;
        //    data.Value = 9448;
        //    datas.Add(data);
        //    data = new ChartTools.Pie3DData();
        //    data.Label = "空头";
        //    data.IsSelected = false;
        //    data.Value = 584;
        //    datas.Add(data);
        //    ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "showDetails4", "showDetailsContent4");
        //    return pie3d.ToString();
        //}

        //public static string ShowDetails5()
        //{
        //    List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
        //    ChartTools.Pie3DData data = new ChartTools.Pie3DData();
        //    data.Label = "多头";
        //    data.IsSelected = true;
        //    data.Value = 948;
        //    datas.Add(data);
        //    data = new ChartTools.Pie3DData();
        //    data.Label = "空头";
        //    data.IsSelected = false;
        //    data.Value = 5584;
        //    datas.Add(data);
        //    ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "showDetails5", "showDetailsContent5");
        //    return pie3d.ToString();
        //}

        //public static string ShowDetails6()
        //{
        //    List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
        //    ChartTools.Pie3DData data = new ChartTools.Pie3DData();
        //    data.Label = "多头";
        //    data.IsSelected = true;
        //    data.Value = 6948;
        //    datas.Add(data);
        //    data = new ChartTools.Pie3DData();
        //    data.Label = "空头";
        //    data.IsSelected = false;
        //    data.Value = 584;
        //    datas.Add(data);
        //    ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "showDetails6", "showDetailsContent6");
        //    return pie3d.ToString();
        //}

        //public static string ShowDetails7()
        //{
        //    List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
        //    ChartTools.Pie3DData data = new ChartTools.Pie3DData();
        //    data.Label = "多头";
        //    data.IsSelected = true;
        //    data.Value = 948;
        //    datas.Add(data);
        //    data = new ChartTools.Pie3DData();
        //    data.Label = "空头";
        //    data.IsSelected = false;
        //    data.Value = 7584;
        //    datas.Add(data);
        //    ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "showDetails7", "showDetailsContent7");
        //    return pie3d.ToString();
        //}

        //public static string ShowDetails8()
        //{
        //    List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
        //    ChartTools.Pie3DData data = new ChartTools.Pie3DData();
        //    data.Label = "多头";
        //    data.IsSelected = true;
        //    data.Value = 948;
        //    datas.Add(data);
        //    data = new ChartTools.Pie3DData();
        //    data.Label = "空头";
        //    data.IsSelected = false;
        //    data.Value = 5848;
        //    datas.Add(data);
        //    ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "showDetails8", "showDetailsContent8");
        //    return pie3d.ToString();
        //}

        //public static string ShowDetails9()
        //{
        //    List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
        //    ChartTools.Pie3DData data = new ChartTools.Pie3DData();
        //    data.Label = "多头";
        //    data.IsSelected = true;
        //    data.Value = 9948;
        //    datas.Add(data);
        //    data = new ChartTools.Pie3DData();
        //    data.Label = "空头";
        //    data.IsSelected = false;
        //    data.Value = 584;
        //    datas.Add(data);
        //    ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "showDetails9", "showDetailsContent9");
        //    return pie3d.ToString();
        //}

        //public static string ShowDetails1Time()
        //{
        //    List<string> names = new List<string>();
        //    names.Add("9:00-9:30");
        //    names.Add("9:30-10:00");
        //    names.Add("10:00-10:30");
        //    names.Add("10:30-11:00");
        //    names.Add("13:00-13:30");
        //    names.Add("13:30-14:00");
        //    names.Add("14:00-14:30");
        //    names.Add("14:30-15:00");

        //    List<ChartTools.Series> datas = new List<ChartTools.Series>();
        //    ChartTools.Series data = new ChartTools.Series();
        //    data.Color = "1D8BD1";
        //    data.Name = "空头";
        //    List<double> ds = new List<double>();
        //    ds.Add(10);
        //    ds.Add(20);
        //    ds.Add(-5);
        //    ds.Add(-9);
        //    ds.Add(10);
        //    ds.Add(20);
        //    ds.Add(-5);
        //    ds.Add(-9);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    data = new ChartTools.Series();
        //    data.Color = "F1683C";
        //    data.Name = "多头";
        //    ds = new List<double>();
        //    ds.Add(4);
        //    ds.Add(2);
        //    ds.Add(-7);
        //    ds.Add(39);
        //    ds.Add(5);
        //    ds.Add(5);
        //    ds.Add(-5);
        //    ds.Add(-9);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "showDetails1Time", "divtime");
        //    return msline.ToString();
        //}
        //public static string ShowDetails2Time()
        //{
        //    List<string> names = new List<string>();
        //    names.Add("9:00-9:30");
        //    names.Add("9:30-10:00");
        //    names.Add("10:00-10:30");
        //    names.Add("10:30-11:00");
        //    names.Add("13:00-13:30");
        //    names.Add("13:30-14:00");
        //    names.Add("14:00-14:30");
        //    names.Add("14:30-15:00");

        //    List<ChartTools.Series> datas = new List<ChartTools.Series>();
        //    ChartTools.Series data = new ChartTools.Series();
        //    data.Color = "1D8BD1";
        //    data.Name = "空头";
        //    List<double> ds = new List<double>();
        //    ds.Add(10);
        //    ds.Add(234);
        //    ds.Add(-5);
        //    ds.Add(-9);
        //    ds.Add(432);
        //    ds.Add(20);
        //    ds.Add(-5);
        //    ds.Add(-9);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    data = new ChartTools.Series();
        //    data.Color = "F1683C";
        //    data.Name = "多头";
        //    ds = new List<double>();
        //    ds.Add(4);
        //    ds.Add(2);
        //    ds.Add(-7);
        //    ds.Add(324);
        //    ds.Add(5);
        //    ds.Add(5);
        //    ds.Add(-5);
        //    ds.Add(-345);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "showDetails2Time", "divtime");
        //    return msline.ToString();
        //}

        //public static string ShowDetails3Time()
        //{
        //    List<string> names = new List<string>();
        //    names.Add("9:00-9:30");
        //    names.Add("9:30-10:00");
        //    names.Add("10:00-10:30");
        //    names.Add("10:30-11:00");
        //    names.Add("13:00-13:30");
        //    names.Add("13:30-14:00");
        //    names.Add("14:00-14:30");
        //    names.Add("14:30-15:00");

        //    List<ChartTools.Series> datas = new List<ChartTools.Series>();
        //    ChartTools.Series data = new ChartTools.Series();
        //    data.Color = "1D8BD1";
        //    data.Name = "空头";
        //    List<double> ds = new List<double>();
        //    ds.Add(34);
        //    ds.Add(20);
        //    ds.Add(-5);
        //    ds.Add(-9);
        //    ds.Add(10);
        //    ds.Add(23);
        //    ds.Add(-5);
        //    ds.Add(-9);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    data = new ChartTools.Series();
        //    data.Color = "F1683C";
        //    data.Name = "多头";
        //    ds = new List<double>();
        //    ds.Add(4);
        //    ds.Add(2);
        //    ds.Add(-7);
        //    ds.Add(54);
        //    ds.Add(5);
        //    ds.Add(5);
        //    ds.Add(435);
        //    ds.Add(-9);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "showDetails3Time", "divtime");
        //    return msline.ToString();
        //}
        //public static string ShowDetails4Time()
        //{
        //    List<string> names = new List<string>();
        //    names.Add("9:00-9:30");
        //    names.Add("9:30-10:00");
        //    names.Add("10:00-10:30");
        //    names.Add("10:30-11:00");
        //    names.Add("13:00-13:30");
        //    names.Add("13:30-14:00");
        //    names.Add("14:00-14:30");
        //    names.Add("14:30-15:00");

        //    List<ChartTools.Series> datas = new List<ChartTools.Series>();
        //    ChartTools.Series data = new ChartTools.Series();
        //    data.Color = "1D8BD1";
        //    data.Name = "空头";
        //    List<double> ds = new List<double>();
        //    ds.Add(10);
        //    ds.Add(23);
        //    ds.Add(-5);
        //    ds.Add(-23);
        //    ds.Add(10);
        //    ds.Add(20);
        //    ds.Add(-23);
        //    ds.Add(-9);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    data = new ChartTools.Series();
        //    data.Color = "F1683C";
        //    data.Name = "多头";
        //    ds = new List<double>();
        //    ds.Add(4);
        //    ds.Add(2);
        //    ds.Add(-23);
        //    ds.Add(39);
        //    ds.Add(23);
        //    ds.Add(5);
        //    ds.Add(-23);
        //    ds.Add(-9);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "showDetails4Time", "divtime");
        //    return msline.ToString();
        //}
        //public static string ShowDetails5Time()
        //{
        //    List<string> names = new List<string>();
        //    names.Add("9:00-9:30");
        //    names.Add("9:30-10:00");
        //    names.Add("10:00-10:30");
        //    names.Add("10:30-11:00");
        //    names.Add("13:00-13:30");
        //    names.Add("13:30-14:00");
        //    names.Add("14:00-14:30");
        //    names.Add("14:30-15:00");

        //    List<ChartTools.Series> datas = new List<ChartTools.Series>();
        //    ChartTools.Series data = new ChartTools.Series();
        //    data.Color = "1D8BD1";
        //    data.Name = "空头";
        //    List<double> ds = new List<double>();
        //    ds.Add(10);
        //    ds.Add(20);
        //    ds.Add(-5);
        //    ds.Add(23);
        //    ds.Add(10);
        //    ds.Add(20);
        //    ds.Add(23);
        //    ds.Add(-9);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    data = new ChartTools.Series();
        //    data.Color = "F1683C";
        //    data.Name = "多头";
        //    ds = new List<double>();
        //    ds.Add(4);
        //    ds.Add(2);
        //    ds.Add(-7);
        //    ds.Add(2);
        //    ds.Add(5);
        //    ds.Add(5);
        //    ds.Add(43);
        //    ds.Add(-9);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "showDetails5Time", "divtime");
        //    return msline.ToString();
        //}
        //public static string ShowDetails6Time()
        //{
        //    List<string> names = new List<string>();
        //    names.Add("9:00-9:30");
        //    names.Add("9:30-10:00");
        //    names.Add("10:00-10:30");
        //    names.Add("10:30-11:00");
        //    names.Add("13:00-13:30");
        //    names.Add("13:30-14:00");
        //    names.Add("14:00-14:30");
        //    names.Add("14:30-15:00");

        //    List<ChartTools.Series> datas = new List<ChartTools.Series>();
        //    ChartTools.Series data = new ChartTools.Series();
        //    data.Color = "1D8BD1";
        //    data.Name = "空头";
        //    List<double> ds = new List<double>();
        //    ds.Add(10);
        //    ds.Add(20);
        //    ds.Add(22);
        //    ds.Add(-9);
        //    ds.Add(10);
        //    ds.Add(20);
        //    ds.Add(21);
        //    ds.Add(-9);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    data = new ChartTools.Series();
        //    data.Color = "F1683C";
        //    data.Name = "多头";
        //    ds = new List<double>();
        //    ds.Add(4);
        //    ds.Add(2);
        //    ds.Add(32);
        //    ds.Add(39);
        //    ds.Add(5);
        //    ds.Add(5);
        //    ds.Add(-5);
        //    ds.Add(32);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "showDetails6Time", "divtime");
        //    return msline.ToString();
        //}

        //public static string ShowDetails7Time()
        //{
        //    List<string> names = new List<string>();
        //    names.Add("9:00-9:30");
        //    names.Add("9:30-10:00");
        //    names.Add("10:00-10:30");
        //    names.Add("10:30-11:00");
        //    names.Add("13:00-13:30");
        //    names.Add("13:30-14:00");
        //    names.Add("14:00-14:30");
        //    names.Add("14:30-15:00");

        //    List<ChartTools.Series> datas = new List<ChartTools.Series>();
        //    ChartTools.Series data = new ChartTools.Series();
        //    data.Color = "1D8BD1";
        //    data.Name = "空头";
        //    List<double> ds = new List<double>();
        //    ds.Add(10);
        //    ds.Add(20);
        //    ds.Add(2345);
        //    ds.Add(-9);
        //    ds.Add(10);
        //    ds.Add(20);
        //    ds.Add(235);
        //    ds.Add(-9);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    data = new ChartTools.Series();
        //    data.Color = "F1683C";
        //    data.Name = "多头";
        //    ds = new List<double>();
        //    ds.Add(4);
        //    ds.Add(2);
        //    ds.Add(327);
        //    ds.Add(39);
        //    ds.Add(5);
        //    ds.Add(5);
        //    ds.Add(-5);
        //    ds.Add(-9);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "showDetails7Time", "divtime");
        //    return msline.ToString();
        //}
        //public static string ShowDetails8Time()
        //{
        //    List<string> names = new List<string>();
        //    names.Add("9:00-9:30");
        //    names.Add("9:30-10:00");
        //    names.Add("10:00-10:30");
        //    names.Add("10:30-11:00");
        //    names.Add("13:00-13:30");
        //    names.Add("13:30-14:00");
        //    names.Add("14:00-14:30");
        //    names.Add("14:30-15:00");

        //    List<ChartTools.Series> datas = new List<ChartTools.Series>();
        //    ChartTools.Series data = new ChartTools.Series();
        //    data.Color = "1D8BD1";
        //    data.Name = "空头";
        //    List<double> ds = new List<double>();
        //    ds.Add(10);
        //    ds.Add(20);
        //    ds.Add(-5);
        //    ds.Add(-9);
        //    ds.Add(10);
        //    ds.Add(20);
        //    ds.Add(-5);
        //    ds.Add(-9);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    data = new ChartTools.Series();
        //    data.Color = "F1683C";
        //    data.Name = "多头";
        //    ds = new List<double>();
        //    ds.Add(4);
        //    ds.Add(2);
        //    ds.Add(-7);
        //    ds.Add(39);
        //    ds.Add(5);
        //    ds.Add(5);
        //    ds.Add(-5);
        //    ds.Add(-9);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "showDetails8Time", "divtime");
        //    return msline.ToString();
        //}
        //public static string ShowDetails9Time()
        //{
        //    List<string> names = new List<string>();
        //    names.Add("9:00-9:30");
        //    names.Add("9:30-10:00");
        //    names.Add("10:00-10:30");
        //    names.Add("10:30-11:00");
        //    names.Add("13:00-13:30");
        //    names.Add("13:30-14:00");
        //    names.Add("14:00-14:30");
        //    names.Add("14:30-15:00");

        //    List<ChartTools.Series> datas = new List<ChartTools.Series>();
        //    ChartTools.Series data = new ChartTools.Series();
        //    data.Color = "1D8BD1";
        //    data.Name = "空头";
        //    List<double> ds = new List<double>();
        //    ds.Add(10);
        //    ds.Add(20);
        //    ds.Add(23);
        //    ds.Add(-9);
        //    ds.Add(10);
        //    ds.Add(20);
        //    ds.Add(-5);
        //    ds.Add(-9);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    data = new ChartTools.Series();
        //    data.Color = "F1683C";
        //    data.Name = "多头";
        //    ds = new List<double>();
        //    ds.Add(4);
        //    ds.Add(2);
        //    ds.Add(43);
        //    ds.Add(39);
        //    ds.Add(5);
        //    ds.Add(5);
        //    ds.Add(-5);
        //    ds.Add(-9);
        //    data.Datas = ds;
        //    datas.Add(data);

        //    ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "showDetails9Time", "divtime");
        //    return msline.ToString();
        //}
        /// <summary>
        /// Tick分布图
        /// </summary>
        /// <param name="ticks"></param>
        /// <param name="playdiv"></param>
        /// <param name="title"></param>
        /// <param name="functionName"></param>
        /// <returns></returns>
        public static string TickPie(List<View.OperatorDayTick> ticks, string playdiv, string title, string functionName)
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            double max = 0;
            if (ticks.Count > 0)
            {
                max = ticks.Max(a => a.Count);
            }
            var query = ticks.Where(a => a.Count > 0);
            if (query.Count() == 0)
            {
                ChartTools.Pie3DData data = new ChartTools.Pie3DData();
                data.Label = "没有记录";
                data.Value = 1;
                data.IsSelected = true;
                datas.Add(data);
            }
            else
            {
                foreach (View.OperatorDayTick tick in ticks)
                {
                    ChartTools.Pie3DData data = new ChartTools.Pie3DData();
                    data.Label = tick.Tick + "个";
                    if (tick.Count == max)
                    {
                        data.IsSelected = true;
                    }
                    else
                    {
                        data.IsSelected = false;
                    }
                    data.Value = tick.Count;
                    datas.Add(data);
                }
            }


            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, functionName, playdiv, title, 130);
            return pie3d.ToString();
        }
        public static string TickPie3()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "1个";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "2个";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "4个";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "TickPie2", "showflash4", "合约盈利的TICK分布饼图", 160);
            return pie3d.ToString();
        }
        /// <summary>
        /// 汇总信息上面的品种收益饼图
        /// </summary>
        /// <param name="tradeHistoryId"></param>
        /// <param name="operatorid"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static string ProductPie(int tradeHistoryId, int operatorid, DB.DBManager db)
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();

            List<View.OperatorDayProductInfo> infos = new View.OperatorDayProductInfo().GetOperatorDayProductInfoIgnoreDirection(tradeHistoryId, operatorid, db);
            foreach (View.OperatorDayProductInfo info in infos)
            {
                var queryExist = datas.Where(a => a.Label.Equals(info.ProductId));
                if (queryExist.Count() == 0)//如果该品种没有在列表中
                {
                    ChartTools.Pie3DData data = new ChartTools.Pie3DData();
                    data.Label = info.ProductId + " 盈利";
                    double allsum = infos.Where(a => a.ProductId.Equals(info.ProductId)).Sum(a => a.Profit);

                    data.IsSelected = false;

                    data.Value = allsum;
                    if (data.Value > 0)
                    {
                        datas.Add(data);
                    }
                }

            }
            if (datas.Count == 0)//如果当日品种交易情况都是亏损
            {
                foreach (View.OperatorDayProductInfo info in infos)
                {
                    var queryExist = datas.Where(a => a.Label.Equals(info.ProductId));
                    if (queryExist.Count() == 0)//如果该品种没有在列表中
                    {
                        ChartTools.Pie3DData data = new ChartTools.Pie3DData();
                        data.Label = info.ProductId + " 亏损";
                        double allsum = infos.Where(a => a.ProductId.Equals(info.ProductId)).Sum(a => a.Profit);

                        data.IsSelected = false;

                        data.Value = Math.Abs(allsum);
                        datas.Add(data);
                    }

                }
            }
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "ProductPie", "showflash2", "品种比率图", 240);
            return pie3d.ToString();
        }
        /// <summary>
        /// 汇总信息上面的品种收益饼图
        /// </summary>
        /// <param name="tradeHistoryId"></param>
        /// <param name="operatorid"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static string GroupBillPic(int week, int year, DB.DBManager db)
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();

            List<BenefitHelper.Data.Week.GroupWeekSum> infos = new BenefitHelper.Data.Week.GroupWeekSum().GetGroupWeekSum(week, year, db);
            foreach (BenefitHelper.Data.Week.GroupWeekSum info in infos)
            {
                ChartTools.Pie3DData data = new ChartTools.Pie3DData();
                data.Label = info.Group.GroupName;
                data.Value = info.BillCount;
                if (data.Value > 0)
                {
                    datas.Add(data);
                }

            }
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "ProductPie", "showflash2", "小组笔数对比", 300);
            return pie3d.ToString();
        }
        /// <summary>
        /// 汇总信息上面的品种收益饼图
        /// </summary>
        /// <param name="tradeHistoryId"></param>
        /// <param name="operatorid"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static string GroupBillPic(int tradeHistoryId, DB.DBManager db)
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            Sys.TradeHistory th = new Sys.TradeHistory();
            th = th.GetModel(tradeHistoryId, db);
            List<BenefitHelper.Data.Day.GroupDayChange> infos = new BenefitHelper.Data.Day.GroupDayChange().GetCompanyDayChange(th.DPdate, th.MPdate, th.YPdate, db);
            foreach (BenefitHelper.Data.Day.GroupDayChange info in infos)
            {
                ChartTools.Pie3DData data = new ChartTools.Pie3DData();
                data.Label = info.Group.GroupName;
                data.Value = info.BillCount;
                if (data.Value > 0)
                {
                    datas.Add(data);
                }

            }
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "ProductPie", "showflash2", "小组笔数对比", 300);
            return pie3d.ToString();
        }
        public static string ProductPie2()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "朱浩";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "李正元";
            data.IsSelected = false;
            data.Value = 32;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "梅祥发";
            data.IsSelected = false;
            data.Value = 34;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "ProductPie5", "showflash5", "交易手数", 160);
            return pie3d.ToString();
        }
        public static string ProductPie3()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "朱浩";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "李正元";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "梅祥发";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "ProductPie6", "showflash6", "交易笔数", 160);
            return pie3d.ToString();
        }
        public static string BSF()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "今天";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data.Label = "昨天";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data.Label = "前天";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data.Label = "9月3日";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data.Label = "9月2日";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "BSF", "showflash3", "五天收益图", 160);
            return pie3d.ToString();
        }
        /// <summary>
        /// 交易员日分时交易信息
        /// </summary>
        /// <param name="info">盈利的日交易信息</param>
        /// <returns></returns>
        public static string BenefitTimePie(View.OperatorDayTradeInfo info, string playdiv, string title, string functionName)
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3D pie3d = null;
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            var query3 = info.Datas.Where(a => a.SumValue > 0);
            if (query3.Count() == 0)
            {
                data = new ChartTools.Pie3DData();
                data.Label = "没有记录";
                data.IsSelected = false;
                data.Value = 1;
                datas.Add(data);
            }
            else
            {
                data = new ChartTools.Pie3DData();
                data.Label = "9:00-9:30";
                data.Value = info.Datas.Where(a => a.Clock == 1).First().SumValue;
                // data.Color = "59a53c";
                if (data.Value > 0)
                {
                    datas.Add(data);
                }
                data = new ChartTools.Pie3DData();
                data.Label = "9:30-10:00";
                data.Value = info.Datas.Where(a => a.Clock == 2).First().SumValue;
                //    data.Color = "9bbc8e";
                if (data.Value > 0)
                {
                    datas.Add(data);
                }
                data = new ChartTools.Pie3DData();
                data.Label = "10:00-10:30";
                data.Value = info.Datas.Where(a => a.Clock == 3).First().SumValue;
                //   data.Color = "184407";
                if (data.Value > 0)
                {
                    datas.Add(data);
                }
                data = new ChartTools.Pie3DData();
                data.Label = "10:30-11:00";
                data.Value = info.Datas.Where(a => a.Clock == 4).First().SumValue;
                //  data.Color = "212c1c";
                if (data.Value > 0)
                {
                    datas.Add(data);
                }
                data = new ChartTools.Pie3DData();
                data.Label = "13:00-13:30";
                data.Value = info.Datas.Where(a => a.Clock == 5).First().SumValue;
                //   data.Color = "194208";
                if (data.Value > 0)
                {
                    datas.Add(data);
                }
                data = new ChartTools.Pie3DData();
                data.Label = "13:30-14:00";
                data.Value = info.Datas.Where(a => a.Clock == 6).First().SumValue;
                //   data.Color = "148c0e";
                if (data.Value > 0)
                {
                    datas.Add(data);
                }
                data = new ChartTools.Pie3DData();
                data.Label = "14:00-14:30";
                data.Value = info.Datas.Where(a => a.Clock == 7).First().SumValue;
                //    data.Color = "3a4f39";
                if (data.Value > 0)
                {
                    datas.Add(data);
                }
                data = new ChartTools.Pie3DData();
                data.Label = "14:30-15:00";
                data.Value = info.Datas.Where(a => a.Clock == 8).First().SumValue;
                //  data.Color = "758b74";
                if (data.Value > 0)
                {
                    datas.Add(data);
                }
                double maxValue = 0;
                if (datas.Count > 0)
                {
                    maxValue = datas.Max(a => a.Value);
                }
                foreach (ChartTools.Pie3DData a in datas)
                {
                    if (a.Value == maxValue)
                    {
                        a.IsSelected = true;
                    }
                    else
                    {
                        a.IsSelected = false;
                    }
                }
            }


            pie3d = new ChartTools.Pie3D(datas, functionName, playdiv, title, 240);

            return pie3d.ToString();
        }

        /// <summary>
        /// 交易员日品种交易图
        /// </summary>
        /// <param name="tradeHistoryId"></param>
        /// <param name="operatorid"></param>
        /// <returns></returns>
        public static string BenefitProductPie(List<BenefitHelper.View.OperatorDayProductInfo> productInfos, string playdiv, string title, string functionName)
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            double max = 0;
            if (productInfos.Count > 0)
            {
                max = productInfos.Max(a => a.Profit);
            }
            foreach (BenefitHelper.View.OperatorDayProductInfo info in productInfos)
            {
                ChartTools.Pie3DData data = new ChartTools.Pie3DData();
                data.Label = info.ProductId;
                if (info.Profit == max)
                {
                    data.IsSelected = true;
                }
                else
                {
                    data.IsSelected = false;
                }
                data.Value = info.Profit;
                datas.Add(data);
            }
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, functionName, playdiv, title, 160);
            return pie3d.ToString();
        }
        /// <summary>
        /// 按多空盈利图
        /// </summary>
        /// <returns></returns>
        public static string BenefitHeadPie(BenefitHelper.View.OperatorDayDirectionInfo info, string showdiv, string title, string functionName)
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            double query = 0;
            if (info.Datas.Count > 0)
            {
                query = info.Datas.Max(a => a.SumValue);
            }

            foreach (BenefitHelper.View.OperatorDayDirectionInfoData data in info.Datas)
            {
                ChartTools.Pie3DData d = new ChartTools.Pie3DData();
                d.Label = data.Direction;
                if (data.SumValue == query)
                {
                    d.IsSelected = true;
                }
                else
                {
                    d.IsSelected = false;
                }
                d.Value = data.SumValue;
                datas.Add(d);
            }
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, functionName, showdiv, title, 160);
            return pie3d.ToString();
        }
        /// <summary>
        /// 按收益情况饼图
        /// </summary>
        /// <param name="dayDatas"></param>
        /// <param name="playdiv"></param>
        /// <param name="title"></param>
        /// <param name="functionName"></param>
        /// <returns></returns>
        public static string BenefitMoneyPie(BenefitHelper.View.OperatorDayWinNum dayDatas, string playdiv, string title, string functionName)
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            double max = 0;
            if (dayDatas.Datas.Count > 0)
            {
                max = dayDatas.Datas.Max(a => a.SumValue);
            }

            foreach (BenefitHelper.View.OperatorDayWinNumData d in dayDatas.Datas)
            {
                ChartTools.Pie3DData data = new ChartTools.Pie3DData();
                data.Label = d.Level + "以下";
                if (d.SumValue == max)
                {
                    data.IsSelected = true;
                }
                else
                {
                    data.IsSelected = false;
                }
                data.Value = d.SumValue;
                datas.Add(data);
            }
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, functionName, playdiv, title, 160);
            return pie3d.ToString();
        }

        //public static string LostTimePie(View.OperatorDayTradeInfo info)
        //{
        //    List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
        //    ChartTools.Pie3DData data = new ChartTools.Pie3DData();
        //    data.Label = "9:00-9:30";
        //    data.Value = info.Datas.Where(a => a.Clock == 1).First().SumValue;
        //    data.Color = "59a53c";
        //    if (data.Value > 0)
        //    {
        //        datas.Add(data);
        //    }
        //    data = new ChartTools.Pie3DData();
        //    data.Label = "9:30-10:00";
        //    data.Value = info.Datas.Where(a => a.Clock == 2).First().SumValue;
        //    data.Color = "9bbc8e";
        //    if (data.Value > 0)
        //    {
        //        datas.Add(data);
        //    }
        //    data = new ChartTools.Pie3DData();
        //    data.Label = "10:00-10:30";
        //    data.Value = info.Datas.Where(a => a.Clock == 3).First().SumValue;
        //    data.Color = "184407";
        //    if (data.Value > 0)
        //    {
        //        datas.Add(data);
        //    }
        //    data = new ChartTools.Pie3DData();
        //    data.Label = "10:30-11:00";
        //    data.Value = info.Datas.Where(a => a.Clock == 4).First().SumValue;
        //    data.Color = "212c1c";
        //    if (data.Value > 0)
        //    {
        //        datas.Add(data);
        //    }
        //    data = new ChartTools.Pie3DData();
        //    data.Label = "13:00-13:30";
        //    data.Value = info.Datas.Where(a => a.Clock == 5).First().SumValue;
        //    data.Color = "194208";
        //    if (data.Value > 0)
        //    {
        //        datas.Add(data);
        //    }
        //    data = new ChartTools.Pie3DData();
        //    data.Label = "13:30-14:00";
        //    data.Value = info.Datas.Where(a => a.Clock == 6).First().SumValue;
        //    data.Color = "148c0e";
        //    if (data.Value > 0)
        //    {
        //        datas.Add(data);
        //    }
        //    data = new ChartTools.Pie3DData();
        //    data.Label = "14:00-14:30";
        //    data.Value = info.Datas.Where(a => a.Clock == 7).First().SumValue;
        //    data.Color = "3a4f39";
        //    if (data.Value > 0)
        //    {
        //        datas.Add(data);
        //    }
        //    data = new ChartTools.Pie3DData();
        //    data.Label = "14:30-15:00";
        //    data.Value = info.Datas.Where(a => a.Clock == 8).First().SumValue;
        //    data.Color = "758b74";
        //    if (data.Value > 0)
        //    {
        //        datas.Add(data);
        //    }
        //    double maxValue = 0;
        //    if (datas.Count > 0)
        //    {
        //        maxValue = datas.Max(a => a.Value);
        //    }
        //    foreach (ChartTools.Pie3DData a in datas)
        //    {
        //        if (a.Value == maxValue)
        //        {
        //            a.IsSelected = true;
        //        }
        //        else
        //        {
        //            a.IsSelected = false;
        //        }
        //    }
        //    ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "BenefitTimePie2", "showflash2", "盈利比率图", false, 160);
        //    return pie3d.ToString();
        //}
        public static string YearPie2()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "1个Tick";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "2个Tick";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "4个Tick";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "5个Tick";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "7个Tick";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "8个Tick";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "9个Tick";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "10个Tick";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "YearPie2", "showflash4", "收益按Tick分布", 160);
            return pie3d.ToString();
        }
        //public static string YearPie(int month, int year, int operatorid, DB.DBManager db)
        //{
        //    List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
        //    List<BenefitHelper.View.OperatorDayTradeInfoData> datas2 = new BenefitHelper.View.OperatorDayTradeInfo().GetMonthTradeInfo(month, year, operatorid, db);
        //    foreach (BenefitHelper.View.OperatorDayTradeInfoData d in datas2)
        //    {
        //        ChartTools.Pie3DData data = new ChartTools.Pie3DData();
        //        if (d.Clock == 1)
        //        {
        //            data.Label = "9:00-9:30";
        //        }
        //        else if (d.Clock == 2)
        //        {
        //            data.Label = "9:30-10:00";
        //        }
        //        else if (d.Clock == 3)
        //        {
        //            data.Label = "10:00-10:30";
        //        }
        //        else if (d.Clock == 4)
        //        {
        //            data.Label = "10:30-11:00";
        //        }
        //        else if (d.Clock == 5)
        //        {
        //            data.Label = "13:00-13:30";
        //        }
        //        else if (d.Clock == 6)
        //        {
        //            data.Label = "13:30-14:00";
        //        }
        //        else if (d.Clock == 7)
        //        {
        //            data.Label = "14:00-14:30";
        //        }
        //        else if (d.Clock == 8)
        //        {
        //            data.Label = "14:30-15:00";
        //        }
        //        data.IsSelected = false;
        //        data.Value = d.BillCount;
        //        datas.Add(data);
        //    }
        //    ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "YearPie", "showflash1", "收益按时间分布", 160);
        //    return pie3d.ToString();
        //}
        public static string GetOperatorAllBenefitPie(int operatorid, int month, int year, bool win, DB.DBManager db)
        {
            List<Sys.TradeHistory> ths = db.TradeHistorys.Where(a => a.YPdate == year).Where(a => a.MPdate == month).ToList();
            List<BenefitHelper.View.OperatorDayTradeInfoData> infos = new List<View.OperatorDayTradeInfoData>();
            foreach (Sys.TradeHistory th in ths)
            {

                if (win)
                {
                    var query = new BenefitHelper.View.OperatorDayTradeInfo().GetOperatorDayTradeInfo(th.Id, operatorid, "sumwin", db);
                    foreach (BenefitHelper.View.OperatorDayTradeInfoData data1 in query.Datas)
                    {
                        infos.Add(data1);
                    }
                }
                else
                {
                    var query = new BenefitHelper.View.OperatorDayTradeInfo().GetOperatorDayTradeInfo(th.Id, operatorid, "sumlose", db);
                    foreach (BenefitHelper.View.OperatorDayTradeInfoData data1 in query.Datas)
                    {
                        infos.Add(data1);
                    }
                }
            }




            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "9:00-9:30";
            data.IsSelected = true;
            data.Value = infos.Where(a => a.Clock == 1).Sum(a => a.SumValue);
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "9:30-10:00";
            data.IsSelected = false;
            data.Value = infos.Where(a => a.Clock == 2).Sum(a => a.SumValue);
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "10:00-10:30";
            data.IsSelected = false;
            data.Value = infos.Where(a => a.Clock == 3).Sum(a => a.SumValue);
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "10:30-11:00";
            data.IsSelected = false;
            data.Value = infos.Where(a => a.Clock == 4).Sum(a => a.SumValue);
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "13:00-13:30";
            data.IsSelected = false;
            data.Value = infos.Where(a => a.Clock == 5).Sum(a => a.SumValue);
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "13:30-14:00";
            data.IsSelected = false;
            data.Value = infos.Where(a => a.Clock == 6).Sum(a => a.SumValue);
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "14:00-14:30";
            data.IsSelected = false;
            data.Value = infos.Where(a => a.Clock == 7).Sum(a => a.SumValue);
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "14:30-15:00";
            data.IsSelected = false;
            data.Value = infos.Where(a => a.Clock == 8).Sum(a => a.SumValue);
            datas.Add(data);
            ChartTools.Pie3D pie3d;

            var query3 = datas.Where(a => a.Value > 0);
            if (query3.Count() == 0)
            {
                datas = new List<Pie3DData>();
                data = new ChartTools.Pie3DData();
                data.Label = "没有记录";
                data.IsSelected = false;
                data.Value = 1;
                datas.Add(data);
            }

            if (win)
            {
                pie3d = new ChartTools.Pie3D(datas, "YearPie2", "showflash3", "盈利按时间分布", 160);
            }
            else
            {
                pie3d = new ChartTools.Pie3D(datas, "YearPie3", "showflash4", "亏损按时间分布", 160);
            }

            return pie3d.ToString();
        }


        public static string GetOperatorYearAllBenefitPie(int operatorid, int year, bool win, DB.DBManager db)
        {
            List<Sys.TradeHistory> ths = db.TradeHistorys.Where(a => a.YPdate == year).ToList();
            List<BenefitHelper.View.OperatorDayTradeInfoData> infos = new List<View.OperatorDayTradeInfoData>();
            foreach (Sys.TradeHistory th in ths)
            {

                if (win)
                {
                    var query = new BenefitHelper.View.OperatorDayTradeInfo().GetOperatorDayTradeInfo(th.Id, operatorid, "sumwin", db);
                    foreach (BenefitHelper.View.OperatorDayTradeInfoData data1 in query.Datas)
                    {
                        infos.Add(data1);
                    }
                }
                else
                {
                    var query = new BenefitHelper.View.OperatorDayTradeInfo().GetOperatorDayTradeInfo(th.Id, operatorid, "sumlose", db);
                    foreach (BenefitHelper.View.OperatorDayTradeInfoData data1 in query.Datas)
                    {
                        infos.Add(data1);
                    }
                }
            }




            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "9:00-9:30";
            data.IsSelected = true;
            data.Value = infos.Where(a => a.Clock == 1).Sum(a => a.SumValue);
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "9:30-10:00";
            data.IsSelected = false;
            data.Value = infos.Where(a => a.Clock == 2).Sum(a => a.SumValue);
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "10:00-10:30";
            data.IsSelected = false;
            data.Value = infos.Where(a => a.Clock == 3).Sum(a => a.SumValue);
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "10:30-11:00";
            data.IsSelected = false;
            data.Value = infos.Where(a => a.Clock == 4).Sum(a => a.SumValue);
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "13:00-13:30";
            data.IsSelected = false;
            data.Value = infos.Where(a => a.Clock == 5).Sum(a => a.SumValue);
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "13:30-14:00";
            data.IsSelected = false;
            data.Value = infos.Where(a => a.Clock == 6).Sum(a => a.SumValue);
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "14:00-14:30";
            data.IsSelected = false;
            data.Value = infos.Where(a => a.Clock == 7).Sum(a => a.SumValue);
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "14:30-15:00";
            data.IsSelected = false;
            data.Value = infos.Where(a => a.Clock == 8).Sum(a => a.SumValue);
            datas.Add(data);
            ChartTools.Pie3D pie3d;
            if (win)
            {
                pie3d = new ChartTools.Pie3D(datas, "YearPie2", "showflash3", "盈利按时间分布", 160);
            }
            else
            {
                pie3d = new ChartTools.Pie3D(datas, "YearPie3", "showflash4", "亏损按时间分布", 160);
            }

            return pie3d.ToString();
        }

        public static string TickPie2()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "1个TICK";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "2个TICK";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "3个TICK";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "4个TICK";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "5个TICK";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "5个TICK";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "7个TICK";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "8个TICK";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "TickPie2", "showflash", "收益按TICK分布", 160);
            return pie3d.ToString();
        }
        public static string TickPie4()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "2000以下";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "200-6000";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "6000-8000";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "8000-10000";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "10000-12000";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "12000-14000";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "14000-16000";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "更多";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "TickPie4", "showflash", "单笔收益分布", 160);
            return pie3d.ToString();
        }
        public static string TickPie5()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "al110";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "al119";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "其他";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "TickPie5", "showflash51", "品种收益分布", 160);
            return pie3d.ToString();
        }
        public static string BenefitProductPie2()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "CU";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "AL";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "BenefitProductPie2", "showflash2", "盈利比率图", 160);
            return pie3d.ToString();
        }

        public static string BenefitHeadPie2()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "多头";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "空头";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "BenefitHeadPie2", "showflash2", "盈利比率图", 160);
            return pie3d.ToString();
        }
        public static string BenefitMoneyPie2()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "100以下";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "200以下";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data.Label = "300以下";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            data.Label = "400以下";
            data.IsSelected = false;
            data.Value = 7584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "BenefitMoneyPie2", "showflash2", "盈利比率图", 160);
            return pie3d.ToString();
        }

        public static string LianxuYingli()
        {
            List<ChartTools.ScatterData> datas = new List<ChartTools.ScatterData>();
            ChartTools.ScatterData data = new ChartTools.ScatterData();
            data.Label = "1";
            data.Value = 1;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "2";
            data.Value = 2;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "3";
            data.Value = 3;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "4";
            data.Value = 4;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "5";
            data.Value = 5;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "6";
            data.Value = 6;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "7";
            data.Value = 7;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "8";
            data.Value = 8;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "9";
            data.Value = 9;
            datas.Add(data);
            List<ChartTools.Point> pdata = new List<ChartTools.Point>();
            ChartTools.Point data2 = new ChartTools.Point();
            data2.X = 5;
            data2.Y = 3.4;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 4;
            data2.Y = 2.4;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 2;
            data2.Y = 5.4;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 5;
            data2.Y = 3.4;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 2;
            data2.Y = 5;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 7;
            data2.Y = 2;
            pdata.Add(data2);
            ChartTools.Scatter pie3d = new ChartTools.Scatter("连续盈利示意图", "盈利次数", "盈利金额", datas, pdata, "LianxuYingli", "showflash2");
            return pie3d.ToString();
        }

        public static string Lianxukuisun()
        {
            List<ChartTools.ScatterData> datas = new List<ChartTools.ScatterData>();
            ChartTools.ScatterData data = new ChartTools.ScatterData();
            data.Label = "1";
            data.Value = 1;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "2";
            data.Value = 2;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "3";
            data.Value = 3;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "4";
            data.Value = 4;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "5";
            data.Value = 5;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "6";
            data.Value = 6;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "7";
            data.Value = 7;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "8";
            data.Value = 8;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "9";
            data.Value = 9;
            datas.Add(data);
            List<ChartTools.Point> pdata = new List<ChartTools.Point>();
            ChartTools.Point data2 = new ChartTools.Point();
            data2.X = 5;
            data2.Y = 3.4;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 4;
            data2.Y = 2.4;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 2;
            data2.Y = 5.4;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 5;
            data2.Y = 3.4;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 2;
            data2.Y = 5;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 7;
            data2.Y = 2;
            pdata.Add(data2);
            ChartTools.Scatter pie3d = new ChartTools.Scatter("连续亏损示意图", "亏损次数", "亏损金额", datas, pdata, "Lianxukuisun", "showflash3");
            return pie3d.ToString();
        }
        /// <summary>
        /// 汇总信息的两个图表
        /// </summary>
        /// <param name="tradeHistoryId"></param>
        /// <param name="operatorid"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static string GetChartJSStringOnHZXI(int tradeHistoryId, int operatorid, DB.DBManager db)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(GetTodayBenefitString(tradeHistoryId, operatorid, db));
            sb.Append(ProductPie(tradeHistoryId, operatorid, db));
            return sb.ToString();
        }

        public static string MonthBenefitString(int groupId, int month, int year, DB.DBManager db)
        {
            List<Data.Day.GroupDayChange> monthsums = new Data.Day.GroupDayChange().GetGroupDayChange(groupId, month, year, db);

            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "当月收益率";
            data.LineName = "累计收益率";
            List<double> coldatas = new List<double>();
            foreach (Data.Day.GroupDayChange _data in monthsums)
            {
                coldatas.Add(_data.Profit);
            }
            data.ColDatas = coldatas;
            List<double> coldatas2 = new List<double>();
            double _sum = 0f;
            foreach (Data.Day.GroupDayChange _data in monthsums)
            {
                _sum += _data.Profit;
                coldatas2.Add(_sum);
            }
            data.LineDatas = coldatas2;
            List<string> names = new List<string>();
            foreach (Data.Day.GroupDayChange _data in monthsums)
            {
                names.Add(_data.TradeHistory.DPdate.ToString());
            }

            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "YearBenefit", "showflash2", "收益率示意图", "changeMonth", "$");
            return d3.ToString();
        }
        /// <summary>
        /// 公司历史数据里面当月收益率和当月累计收益图
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static string CompanyMonthBenefitString(int month, int year, DB.DBManager db)
        {
            List<Data.Day.CompanyDayChange> monthsums = new Data.Day.CompanyDayChange().GetCompanyDayChange(month, year, db);

            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "当月收益率";
            data.LineName = "累计收益率";
            List<double> coldatas = new List<double>();
            foreach (Data.Day.CompanyDayChange _data in monthsums)
            {
                coldatas.Add(_data.Yield);
            }
            data.ColDatas = coldatas;
            List<double> coldatas2 = new List<double>();
            double _sum = 0f;
            foreach (Data.Day.CompanyDayChange _data in monthsums)
            {
                _sum += _data.Yield;
                coldatas2.Add(_sum);
            }
            data.LineDatas = coldatas2;
            List<string> names = new List<string>();
            foreach (Data.Day.CompanyDayChange _data in monthsums)
            {
                names.Add(_data.TradeHistory.DPdate.ToString());
            }

            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "YearBenefit", "showflash2", "收益率示意图", "changeMonth", "$");
            return d3.ToString();
        }
        /// <summary>
        /// 公司历史数据里面当年收益率和当年累计收益图
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static string CompanyYearBenefitString(int year, DB.DBManager db)
        {
            List<Data.Month.CompanyMonthSum> monthsums = new Data.Month.CompanyMonthSum().GetCompanyMonthSum(year, db);

            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "当月收益率";
            data.LineName = "累计收益率";
            List<double> coldatas = new List<double>();
            foreach (Data.Month.CompanyMonthSum _data in monthsums)
            {
                coldatas.Add(_data.Yield);
            }
            data.ColDatas = coldatas;
            List<double> coldatas2 = new List<double>();
            double _sum = 0f;
            foreach (Data.Month.CompanyMonthSum _data in monthsums)
            {
                _sum += _data.Yield;
                coldatas2.Add(_sum);
            }
            data.LineDatas = coldatas2;
            List<string> names = new List<string>();
            foreach (Data.Month.CompanyMonthSum _data in monthsums)
            {
                names.Add(_data.Month.ToString());
            }

            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "YearBenefit", "showflash2", "收益率示意图", "changeMonth", "$");
            return d3.ToString();
        }
        public static string YearBenefitString(int groupId, int year, DB.DBManager db)
        {
            List<Data.Month.GroupMonthSum> monthsums = new Data.Month.GroupMonthSum().GetMonthSum(groupId, year, db);

            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "当月收益率";
            data.LineName = "累计收益率";
            List<double> coldatas = new List<double>();
            foreach (Data.Month.GroupMonthSum _data in monthsums)
            {
                coldatas.Add(_data.Profit);
            }
            data.ColDatas = coldatas;
            List<double> coldatas2 = new List<double>();
            double _sum = 0f;
            foreach (Data.Month.GroupMonthSum _data in monthsums)
            {
                _sum += _data.Profit;
                coldatas2.Add(_sum);
            }
            data.LineDatas = coldatas2;
            List<string> names = new List<string>();
            foreach (Data.Month.GroupMonthSum _data in monthsums)
            {
                names.Add(_data.Month.ToString());
            }

            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "YearBenefit", "showflash2", "收益率示意图", "changeMonth", "$");
            return d3.ToString();
        }


        /// <summary>
        /// 得到交易员某月的交易曲线(OK)
        /// </summary>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <param name="opeartorid"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static string GetOperatorMonthYieldString(int month, int year, int operatorid, DB.DBManager db)
        {
            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "当月收益率";
            data.LineName = "累计收益率";
            var query = db.OperatorDayChange.Where(a => a.TradeHistory.YPdate == year).Where(a => a.TradeHistory.MPdate == month).Where(a => a.OperatorId == operatorid).ToList();
            List<double> coldatas = new List<double>();
            List<double> coldatas2 = new List<double>();
            List<string> names = new List<string>();
            double total = 0;
            foreach (BenefitHelper.View.OperatorDayChange change in query)
            {
                coldatas.Add(change.Yield);
                total += change.Yield;
                coldatas2.Add(total);
                names.Add(change.TradeHistory.DPdate.ToString());
            }
            data.ColDatas = coldatas;
            data.LineDatas = coldatas2;
            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "YearBenefit", "showflash", "收益示意图", "changeMonth", "$");
            return d3.ToString();
        }
        /// <summary>
        /// 得到交易员某年的交易曲线(OK)
        /// </summary>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <param name="opeartorid"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static string GetOperatorYearYieldString(int year, int operatorid, DB.DBManager db)
        {
            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "当年收益率";
            data.LineName = "累计收益率";
            var query = db.OperatorDayChange.Where(a => a.TradeHistory.YPdate == year).Where(a => a.OperatorId == operatorid).ToList();
            List<double> coldatas = new List<double>();
            List<double> coldatas2 = new List<double>();
            List<string> names = new List<string>();
            double total = 0;
            foreach (BenefitHelper.View.OperatorDayChange change in query)
            {
                coldatas.Add(change.Yield);
                total += change.Yield;
                coldatas2.Add(total);
                names.Add(change.TradeHistory.DPdate.ToString());
            }
            data.ColDatas = coldatas;
            data.LineDatas = coldatas2;
            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "YearBenefit", "showflash", "收益示意图", "changeMonth", "$");
            return d3.ToString();
        }
        /// <summary>
        /// 持仓分析上面的成交笔数按时间分布
        /// </summary>
        /// <returns></returns>
        public static string GetChartBillCountOnCCFX(int tradeHistoryId, int operatorid, DB.DBManager db)
        {
            View.OperatorDayTradeInfo info = new View.OperatorDayTradeInfo();
            info = info.GetOperatorDayTradeInfo(tradeHistoryId, operatorid, "billcount", db);
            ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
            data.ColName = "成交笔数";
            List<double> coldatas = new List<double>();

            foreach (View.OperatorDayTradeInfoData i in info.Datas)
            {
                coldatas.Add(i.BillCount);
            }

            data.ColDatas = coldatas;
            List<string> names = new List<string>();
            names.Add("9:30");
            names.Add("10:00");
            names.Add("10:30");
            names.Add("11:00");
            names.Add("13:30");
            names.Add("14:00");
            names.Add("14:30");
            names.Add("15:00");
            data.Labels = names;
            ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "BillCount", "showflash3", "成交笔数按时间分布", "changeMonth", "");
            return d3.ToString();
        }
        ///// <summary>
        ///// 持仓分析上面的成交笔数按时间分布
        ///// </summary>
        ///// <returns></returns>
        //public static string MonthBillCount(int month, int year, int operatorid, DB.DBManager db)
        //{
        //    View.OperatorDayTradeInfo info = new View.OperatorDayTradeInfo();
        //    info = info.GetOperatorDayTradeInfo(tradeHistoryId, operatorid, "billcount", db);
        //    ChartTools.Col3DLineDY3Data data = new ChartTools.Col3DLineDY3Data();
        //    data.ColName = "成交笔数";
        //    List<double> coldatas = new List<double>();

        //    foreach (View.OperatorDayTradeInfoData i in info.Datas)
        //    {
        //        coldatas.Add(i.BillCount);
        //    }

        //    data.ColDatas = coldatas;
        //    List<string> names = new List<string>();
        //    names.Add("9:30");
        //    names.Add("10:00");
        //    names.Add("10:30");
        //    names.Add("11:00");
        //    names.Add("13:30");
        //    names.Add("14:00");
        //    names.Add("14:30");
        //    names.Add("15:00");
        //    data.Labels = names;
        //    ChartTools.Col3DLineDY3 d3 = new ChartTools.Col3DLineDY3(data, "BillCount", "showflash3", "成交笔数按时间分布", "changeMonth", "");
        //    return d3.ToString();
        //}
        public static string BillWinLose()
        {
            List<ChartTools.ScatterData> datas = new List<ChartTools.ScatterData>();
            ChartTools.ScatterData data = new ChartTools.ScatterData();
            data.Label = "1";
            data.Value = 1;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "30";
            data.Value = 30;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "60";
            data.Value = 60;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "90";
            data.Value = 90;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "120";
            data.Value = 120;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "150";
            data.Value = 150;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "180";
            data.Value = 180;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "210";
            data.Value = 210;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "240";
            data.Value = 240;
            datas.Add(data);
            List<ChartTools.Point> pdata = new List<ChartTools.Point>();
            ChartTools.Point data2 = new ChartTools.Point();
            data2.X = 1;
            data2.Y = 3.4;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 2;
            data2.Y = 2.4;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 3;
            data2.Y = 5.4;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 120;
            data2.Y = 3.4;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 140;
            data2.Y = 5;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 210;
            data2.Y = 2;
            pdata.Add(data2);

            List<ChartTools.Point> pdata2 = new List<ChartTools.Point>();
            ChartTools.Point data3 = new ChartTools.Point();
            data3.X = 2;
            data3.Y = 6.4;
            pdata2.Add(data3);
            data3 = new ChartTools.Point();
            data3.X = 3;
            data3.Y = 4.4;
            pdata2.Add(data3);
            data3 = new ChartTools.Point();
            data3.X = 1;
            data3.Y = 2.4;
            pdata2.Add(data3);
            data3 = new ChartTools.Point();
            data3.X = 220;
            data3.Y = 5.4;
            pdata2.Add(data3);
            data3 = new ChartTools.Point();
            data3.X = 100;
            data3.Y = 4;
            pdata2.Add(data3);
            data3 = new ChartTools.Point();
            data3.X = 35;
            data3.Y = 3;
            pdata2.Add(data3);

            ChartTools.Scatter pie3d = new ChartTools.Scatter("盈亏示意图", "下单量", "Tick", datas, "空", "多", pdata, pdata2, "BillWinLose", "showflash3");
            return pie3d.ToString();
        }

        public static string MonthAreaPic()
        {
            ChartTools.MSAreaData datas = new ChartTools.MSAreaData();
            datas.LabelName = "";
            List<double> data = new List<double>();
            data.Add(0.4);
            data.Add(0.3);
            data.Add(0.4);
            data.Add(0.5);
            data.Add(0.6);
            data.Add(0.7);
            data.Add(0.8);
            data.Add(0.9);
            data.Add(0.98);
            data.Add(0.99);
            datas.Datas = data;
            List<string> labels = new List<string>();
            labels.Add("1日");
            labels.Add("2日");
            labels.Add("3日");
            labels.Add("4日");
            labels.Add("5日");
            labels.Add("6日");
            labels.Add("7日");
            labels.Add("8日");
            labels.Add("9日");
            labels.Add("10日");
            labels.Add("11日");
            labels.Add("12日");
            labels.Add("13日");
            labels.Add("14日");



            List<ChartTools.MSAreaData> ds = new List<ChartTools.MSAreaData>();
            ds.Add(datas);
            ChartTools.MSArea pie3d = new ChartTools.MSArea(labels, ds, "msarea2", "showflash2", "收益率", "日期", "月收益率");
            return pie3d.ToString();
        }
        public static string MonthAreaBenefitPic(int groupId, int month, int year, DB.DBManager db)
        {
            Data.Day.GroupDayChange monthsum = new Data.Day.GroupDayChange();
            List<Data.Day.GroupDayChange> sums = monthsum.GetGroupDayChange(groupId, month, year, db);
            ChartTools.MSAreaData datas = new ChartTools.MSAreaData();
            datas.LabelName = "";
            List<double> data = new List<double>();
            foreach (Data.Day.GroupDayChange s in sums)
            {
                data.Add(s.Yield);
            }

            datas.Datas = data;
            List<string> labels = new List<string>();
            foreach (Data.Day.GroupDayChange s in sums)
            {
                labels.Add(s.TradeHistory.DPdate.ToString() + "日");
            }

            List<ChartTools.MSAreaData> ds = new List<ChartTools.MSAreaData>();
            ds.Add(datas);
            ChartTools.MSArea pie3d = new ChartTools.MSArea(labels, ds, "MonthAreaBenefitPic", "showflash2", "收益率", "日期", "收益率");
            return pie3d.ToString();
        }
        public static string YearAreaBenefitPic(int groupId, int year, DB.DBManager db)
        {
            Data.Month.GroupMonthSum monthsum = new Data.Month.GroupMonthSum();
            List<Data.Month.GroupMonthSum> sums = monthsum.GetMonthSum(groupId, year, db);
            ChartTools.MSAreaData datas = new ChartTools.MSAreaData();
            datas.LabelName = "";
            List<double> data = new List<double>();
            foreach (Data.Month.GroupMonthSum s in sums)
            {
                data.Add(s.Yield);
            }

            datas.Datas = data;
            List<string> labels = new List<string>();
            foreach (Data.Month.GroupMonthSum s in sums)
            {
                labels.Add(s.Month.ToString() + "月");
            }

            List<ChartTools.MSAreaData> ds = new List<ChartTools.MSAreaData>();
            ds.Add(datas);
            ChartTools.MSArea pie3d = new ChartTools.MSArea(labels, ds, "MonthAreaBenefitPic", "showflash2", "收益率", "日期", "收益率");
            return pie3d.ToString();
        }
        public static string ZhangFuArea()
        {
            List<string> names = new List<string>();
            names.Add("1");
            names.Add("2");
            names.Add("3");
            names.Add("4");
            names.Add("5");
            names.Add("6");
            names.Add("7");
            names.Add("8");
            names.Add("9");
            names.Add("10");
            names.Add("11");
            names.Add("12");
            names.Add("13");
            names.Add("14");
            names.Add("15");
            names.Add("16");
            List<ChartTools.Series> datas = new List<ChartTools.Series>();
            ChartTools.Series data = new ChartTools.Series();
            //   data.Color = "1D8BD1";
            data.Name = "成长率";
            List<double> ds = new List<double>();
            ds.Add(10);
            ds.Add(20);
            ds.Add(23);
            ds.Add(-9);
            ds.Add(10);
            ds.Add(20);
            ds.Add(-5);
            ds.Add(-9);
            ds.Add(10);
            ds.Add(20);
            ds.Add(23);
            ds.Add(-9);
            ds.Add(10);
            ds.Add(20);
            ds.Add(-5);
            ds.Add(-9);
            data.Datas = ds;
            datas.Add(data);

            ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "ZhangFuArea", "showflash4");
            return msline.ToString();
        }
        public static string BaiDongZhiShu()
        {
            List<string> names = new List<string>();
            names.Add("1");
            names.Add("2");
            names.Add("3");
            names.Add("4");
            names.Add("5");
            names.Add("6");
            names.Add("7");
            names.Add("8");
            names.Add("9");
            names.Add("10");
            names.Add("11");
            names.Add("12");
            names.Add("13");
            names.Add("14");
            names.Add("15");
            names.Add("16");
            List<ChartTools.Series> datas = new List<ChartTools.Series>();
            ChartTools.Series data = new ChartTools.Series();
            //  data.Color = "1D8BD1";
            data.Name = "稳定指数";
            List<double> ds = new List<double>();
            ds.Add(10);
            ds.Add(20);
            ds.Add(23);
            ds.Add(-9);
            ds.Add(10);
            ds.Add(20);
            ds.Add(-5);
            ds.Add(-9);
            ds.Add(10);
            ds.Add(20);
            ds.Add(23);
            ds.Add(-9);
            ds.Add(10);
            ds.Add(20);
            ds.Add(-5);
            ds.Add(-9);
            data.Datas = ds;
            datas.Add(data);

            ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "BaiDongZhiShu", "showflash5");
            return msline.ToString();
        }
        public static string YingliPic()
        {
            ChartTools.MSAreaData datas = new ChartTools.MSAreaData();
            datas.LabelName = "";
            List<double> data = new List<double>();
            data.Add(0.4);
            data.Add(0.3);
            datas.Datas = data;
            List<string> labels = new List<string>();
            labels.Add("CU");
            labels.Add("AL");
            List<ChartTools.MSAreaData> ds = new List<ChartTools.MSAreaData>();
            ds.Add(datas);
            ChartTools.MSArea pie3d = new ChartTools.MSArea(labels, ds, "msarea2", "showflash2", "收益", "品种", "品种收益图");
            return pie3d.ToString();
        }

        public static string changxian1()
        {
            List<ChartTools.MSAreaData> ds = new List<ChartTools.MSAreaData>();
            ChartTools.MSAreaData datas = new ChartTools.MSAreaData();
            datas.LabelName = "平仓盈亏";
            List<double> data = new List<double>();
            data.Add(0.4);
            data.Add(0.3);
            data.Add(0.4);
            data.Add(0.5);
            data.Add(0.6);
            data.Add(0.7);
            data.Add(0.8);
            data.Add(0.9);
            data.Add(0.98);
            data.Add(0.99);
            datas.Datas = data;
            ds.Add(datas);
            datas = new ChartTools.MSAreaData();
            datas.LabelName = "浮动盈亏";
            List<double> data2 = new List<double>();
            data2.Add(0.3);
            data2.Add(0.4);
            data2.Add(0.5);
            data2.Add(0.6);
            data2.Add(0.7);
            data2.Add(0.8);
            data2.Add(0.9);
            data2.Add(0.4);
            data2.Add(0.6);
            data2.Add(0.7);
            datas.Datas = data2;
            ds.Add(datas);
            List<string> labels = new List<string>();
            labels.Add("1");
            labels.Add("2");
            labels.Add("3");
            labels.Add("4");
            labels.Add("5");
            labels.Add("6");
            labels.Add("7");
            labels.Add("8");
            labels.Add("9");


            ChartTools.MSArea pie3d = new ChartTools.MSArea(labels, ds, "changxian1", "showflash", "收益示意图", "", "");
            return pie3d.ToString();
        }
        public static string KuisunPic()
        {
            ChartTools.MSAreaData datas = new ChartTools.MSAreaData();
            datas.LabelName = "";
            List<double> data = new List<double>();
            data.Add(0.4);
            data.Add(0.3);
            datas.Datas = data;
            List<string> labels = new List<string>();
            labels.Add("CU");
            labels.Add("AL");
            List<ChartTools.MSAreaData> ds = new List<ChartTools.MSAreaData>();
            ds.Add(datas);
            ChartTools.MSArea pie3d = new ChartTools.MSArea(labels, ds, "msarea2", "showflash2", "收益", "品种", "品种亏损图");
            return pie3d.ToString();
        }
        public static string YearAreaPic()
        {
            ChartTools.MSAreaData datas = new ChartTools.MSAreaData();
            datas.LabelName = "";
            List<double> data = new List<double>();
            data.Add(0.4);
            data.Add(0.3);
            data.Add(0.4);
            data.Add(0.5);
            data.Add(0.6);
            data.Add(0.7);
            data.Add(0.8);
            data.Add(0.9);
            data.Add(0.98);
            data.Add(0.99);
            data.Add(2);
            data.Add(2.6);
            datas.Datas = data;
            List<string> labels = new List<string>();
            labels.Add("1");
            labels.Add("2");
            labels.Add("3");
            labels.Add("4");
            labels.Add("5");
            labels.Add("6");
            labels.Add("7");
            labels.Add("8");
            labels.Add("9");
            labels.Add("10");
            labels.Add("11");
            labels.Add("12");
            labels.Add("13");
            labels.Add("14");
            labels.Add("15");
            labels.Add("16");
            labels.Add("17");
            labels.Add("18");
            labels.Add("19");
            labels.Add("20");
            labels.Add("21");
            labels.Add("22");
            labels.Add("23");
            labels.Add("24");
            labels.Add("25");
            labels.Add("26");
            labels.Add("27");
            labels.Add("28");
            labels.Add("29");
            labels.Add("30");
            labels.Add("31");
            List<ChartTools.MSAreaData> ds = new List<ChartTools.MSAreaData>();
            ds.Add(datas);
            ChartTools.MSArea pie3d = new ChartTools.MSArea(labels, ds, "msarea", "showflash", "收益效率", "月份", "月收益率效率");
            return pie3d.ToString();
        }
        /// <summary>
        /// 公司历史数据的今天和去年同期的月比较图
        /// </summary>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static string DayShouyilv(int month, int year, DB.DBManager db)
        {
            int yestermonth = month;
            int yesteryear = year - 1;

            List<int> datalist1 = new List<int>();
            List<int> datalist2 = new List<int>();


            List<BenefitHelper.Data.Day.CompanyDayChange> changes = new BenefitHelper.Data.Day.CompanyDayChange().GetCompanyDayChange(yestermonth, yesteryear, db);
            List<ChartTools.MSAreaData> ds = new List<ChartTools.MSAreaData>();
            ChartTools.MSAreaData datas = new ChartTools.MSAreaData();
            datas.LabelName = "去年同期";
            List<double> data = new List<double>();
            foreach (BenefitHelper.Data.Day.CompanyDayChange d in changes)
            {
                //  data.Add(d.Profit);
                datalist1.Add(d.TradeHistory.DPdate);
            }
            ChartTools.MSAreaData datas2 = new ChartTools.MSAreaData();
            datas2 = new ChartTools.MSAreaData();
            List<BenefitHelper.Data.Day.CompanyDayChange> changes2 = new BenefitHelper.Data.Day.CompanyDayChange().GetCompanyDayChange(month, year, db);


            datas2.LabelName = "今年";
            List<double> data2 = new List<double>();
            foreach (BenefitHelper.Data.Day.CompanyDayChange d in changes2)
            {
                //  data2.Add(d.Profit);
                datalist2.Add(d.TradeHistory.DPdate);
            }
            var list = CompareList(datalist1, datalist2);









            List<string> labels = new List<string>();
            foreach (int i in list)
            {
                labels.Add(i.ToString());
            }


            foreach (int i in list)
            {
                var query = changes.Where(a => a.TradeHistory.DPdate == i);
                if (query.Count() > 0)
                {
                    data.Add(query.First().Profit);
                }
                else
                {
                    data.Add(0);
                }
            }
            datas.Datas = data;
            ds.Add(datas);
            foreach (int i in list)
            {
                var query = changes2.Where(a => a.TradeHistory.DPdate == i);
                if (query.Count() > 0)
                {
                    data2.Add(query.First().Profit);
                }
                else
                {
                    data2.Add(0);
                }
            }
            datas2.Datas = data2;
            ds.Add(datas2);
            ChartTools.MSArea pie3d = new ChartTools.MSArea(labels, ds, "DayShouyilv", "showflash", "收益", "", "");
            return pie3d.ToString();
        }
        /// <summary>
        /// 公司历史数据的今天和去年同期的月比较图
        /// </summary>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static string MonthShouyilv(int year, DB.DBManager db)
        {
            int yesteryear = year - 1;

            List<int> datalist1 = new List<int>();
            List<int> datalist2 = new List<int>();


            List<BenefitHelper.Data.Month.CompanyMonthSum> changes = new BenefitHelper.Data.Month.CompanyMonthSum().GetCompanyMonthSum(yesteryear, db);
            List<ChartTools.MSAreaData> ds = new List<ChartTools.MSAreaData>();
            ChartTools.MSAreaData datas = new ChartTools.MSAreaData();
            datas.LabelName = "去年";
            List<double> data = new List<double>();
            foreach (BenefitHelper.Data.Month.CompanyMonthSum d in changes)
            {
                //  data.Add(d.Profit);
                datalist1.Add(d.Month);
            }
            ChartTools.MSAreaData datas2 = new ChartTools.MSAreaData();
            datas2 = new ChartTools.MSAreaData();
            List<BenefitHelper.Data.Month.CompanyMonthSum> changes2 = new BenefitHelper.Data.Month.CompanyMonthSum().GetCompanyMonthSum(year, db);


            datas2.LabelName = "今年";
            List<double> data2 = new List<double>();
            foreach (BenefitHelper.Data.Month.CompanyMonthSum d in changes2)
            {
                //  data2.Add(d.Profit);
                datalist2.Add(d.Month);
            }
            var list = CompareList(datalist1, datalist2);









            List<string> labels = new List<string>();
            foreach (int i in list)
            {
                labels.Add(i.ToString());
            }


            foreach (int i in list)
            {
                var query = changes.Where(a => a.Month == i);
                if (query.Count() > 0)
                {
                    data.Add(query.First().Profit);
                }
                else
                {
                    data.Add(0);
                }
            }
            datas.Datas = data;
            ds.Add(datas);
            foreach (int i in list)
            {
                var query = changes2.Where(a => a.Month == i);
                if (query.Count() > 0)
                {
                    data2.Add(query.First().Profit);
                }
                else
                {
                    data2.Add(0);
                }
            }
            datas2.Datas = data2;
            ds.Add(datas2);
            ChartTools.MSArea pie3d = new ChartTools.MSArea(labels, ds, "DayShouyilv", "showflash", "收益", "", "");
            return pie3d.ToString();
        }
        public static List<int> CompareList(List<int> list1, List<int> list2)
        {
            List<int> list = new List<int>();
            foreach (int i in list1)
            {
                list.Add(i);
            }
            foreach (int i in list2)
            {
                if (!list.Contains(i))
                {
                    list.Add(i);
                }
            }
            list.Sort();
            return list;
        }

        public static string Lianxuyingkui()
        {
            List<ChartTools.ScatterData> datas = new List<ChartTools.ScatterData>();
            ChartTools.ScatterData data = new ChartTools.ScatterData();
            data.Label = "2";
            data.Value = 2;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "3";
            data.Value = 3;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "4";
            data.Value = 4;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "5";
            data.Value = 5;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "6";
            data.Value = 6;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "7";
            data.Value = 7;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "8";
            data.Value = 8;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "9";
            data.Value = 9;
            datas.Add(data);
            data = new ChartTools.ScatterData();
            data.Label = "10";
            data.Value = 10;
            datas.Add(data);
            List<ChartTools.Point> pdata = new List<ChartTools.Point>();
            ChartTools.Point data2 = new ChartTools.Point();
            data2.X = 2;
            data2.Y = 3.4;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 2;
            data2.Y = 2.4;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 3;
            data2.Y = 5.4;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 4;
            data2.Y = 3.4;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 5;
            data2.Y = 5;
            pdata.Add(data2);
            data2 = new ChartTools.Point();
            data2.X = 6;
            data2.Y = 2;
            pdata.Add(data2);

            List<ChartTools.Point> pdata2 = new List<ChartTools.Point>();
            ChartTools.Point data3 = new ChartTools.Point();
            data3.X = 2;
            data3.Y = 6.4;
            pdata2.Add(data3);
            data3 = new ChartTools.Point();
            data3.X = 2;
            data3.Y = 4.4;
            pdata2.Add(data3);
            data3 = new ChartTools.Point();
            data3.X = 3;
            data3.Y = 2.4;
            pdata2.Add(data3);
            data3 = new ChartTools.Point();
            data3.X = 4;
            data3.Y = 5.4;
            pdata2.Add(data3);
            data3 = new ChartTools.Point();
            data3.X = 4;
            data3.Y = 4;
            pdata2.Add(data3);
            data3 = new ChartTools.Point();
            data3.X = 5;
            data3.Y = 3;
            pdata2.Add(data3);

            ChartTools.Scatter pie3d = new ChartTools.Scatter("连续盈亏示意图", "连续盈利次数", "盈亏额", datas, "盈利", "亏损", pdata, pdata2, "lianxuyingk", "showflash");
            return pie3d.ToString();
        }


        public static string ShouYiBiLVLine(int operatorid, int month, int year, DB.DBManager db)
        {
            List<string> names = new List<string>();
            List<BenefitHelper.View.OperatorDayChange> moneys = db.OperatorDayChange.Where(a => a.TradeHistory.MPdate == month).Where(a => a.TradeHistory.YPdate == year).Where(a => a.OperatorId == operatorid).Include(a => a.TradeHistory).ToList();
            foreach (BenefitHelper.View.OperatorDayChange change in moneys)
            {
                names.Add(change.TradeHistory.DPdate.ToString());
            }
            List<ChartTools.Series> datas = new List<ChartTools.Series>();
            ChartTools.Series data = new ChartTools.Series();
            // data.Color = "1D8BD1";
            data.Name = "收益率";
            List<double> ds = new List<double>();
            foreach (BenefitHelper.View.OperatorDayChange change in moneys)
            {
                ds.Add(change.Yield);
            }
            data.Datas = ds;
            datas.Add(data);

            ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "ShouYiBiLVLine", "showflash5");
            return msline.ToString();
        }
        public static string ShouYiBiLVYearLine(int operatorid, int year, DB.DBManager db)
        {
            List<string> names = new List<string>();
            List<BenefitHelper.View.OperatorMonthSum> moneys = db.OperatorMonthSun.Where(a => a.Year == year).Where(a => a.OperatorId == operatorid).ToList();
            foreach (BenefitHelper.View.OperatorMonthSum change in moneys)
            {
                names.Add(change.Month.ToString());
            }
            List<ChartTools.Series> datas = new List<ChartTools.Series>();
            ChartTools.Series data = new ChartTools.Series();
            //  data.Color = "1D8BD1";
            data.Name = "收益比率";
            List<double> ds = new List<double>();
            foreach (BenefitHelper.View.OperatorMonthSum change in moneys)
            {
                ds.Add(change.Yield);
            }
            data.Datas = ds;
            datas.Add(data);

            ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "ShouYiBiLVLine", "showflash5");
            return msline.ToString();
        }
        public static string ShouYiBiLVLine23()
        {
            List<string> names = new List<string>();
            names.Add("1");
            names.Add("2");
            names.Add("3");
            names.Add("4");
            names.Add("5");
            names.Add("6");
            names.Add("7");
            names.Add("8");
            names.Add("9");
            names.Add("10");
            names.Add("11");
            names.Add("12");
            List<ChartTools.Series> datas = new List<ChartTools.Series>();
            ChartTools.Series data = new ChartTools.Series();
            //  data.Color = "1D8BD1";
            data.Name = "收益率";
            List<double> ds = new List<double>();
            ds.Add(10);
            ds.Add(20);
            ds.Add(23);
            ds.Add(-9);
            ds.Add(10);
            ds.Add(20);
            ds.Add(-5);
            ds.Add(-9);
            data.Datas = ds;
            datas.Add(data);

            ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "ShouYiBiLVLine", "showflash5");
            return msline.ToString();
        }

        public static string ShouYiBiLVLine24()
        {
            List<string> names = new List<string>();
            names.Add("1");
            names.Add("2");
            names.Add("3");
            names.Add("4");
            names.Add("5");
            names.Add("6");
            names.Add("7");
            names.Add("8");
            names.Add("9");
            names.Add("10");
            names.Add("11");
            names.Add("12");
            List<ChartTools.Series> datas = new List<ChartTools.Series>();
            ChartTools.Series data = new ChartTools.Series();
            //   data.Color = "1D8BD1";
            data.Name = "客户权益";
            List<double> ds = new List<double>();
            ds.Add(10);
            ds.Add(20);
            ds.Add(23);
            ds.Add(-9);
            ds.Add(10);
            ds.Add(20);
            ds.Add(-5);
            ds.Add(-9);
            data.Datas = ds;
            datas.Add(data);

            ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "ShouYiBiLVLine24", "showflash");
            return msline.ToString();
        }

        /// <summary>
        /// 持仓时间与收益率的关系图
        /// </summary>
        /// <param name="tradeHistoryId"></param>
        /// <param name="operatorId"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static string GetChartYieldOnCCFX(int tradeHistoryId, int operatorId, DB.DBManager db)
        {
            List<View.OperatorYieldInHoldTime> lists = new View.OperatorYieldInHoldTime().GetOperatorYieldInHoldTime(tradeHistoryId, operatorId, db);
            List<string> names = new List<string>();
            lists.OrderBy(a => a.HoldTime);
            foreach (View.OperatorYieldInHoldTime time in lists)
            {
                names.Add(time.HoldTime + "秒");
            }

            List<ChartTools.Series> datas = new List<ChartTools.Series>();
            ChartTools.Series data = new ChartTools.Series();
            //  data.Color = "1D8BD1";
            data.Name = "收益率";
            List<double> ds = new List<double>();
            foreach (View.OperatorYieldInHoldTime time in lists)
            {
                ds.Add(time.Yield);
            }
            data.Datas = ds;
            datas.Add(data);

            ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "ShouYiBiLVLine", "showflash");
            return msline.ToString();
        }
        public static string TwoLine()
        {
            List<string> names = new List<string>();
            names.Add("9:00");
            names.Add("9:30");
            names.Add("10:00");
            names.Add("10:30");
            names.Add("13:00");
            names.Add("13:30");
            names.Add("14:00");
            names.Add("14:30");

            List<ChartTools.Series> datas = new List<ChartTools.Series>();
            ChartTools.Series data = new ChartTools.Series();
            //  data.Color = "1D8BD1";
            data.Name = "今日";
            List<double> ds = new List<double>();
            ds.Add(10);
            ds.Add(20);
            ds.Add(23);
            ds.Add(-9);
            ds.Add(10);
            ds.Add(20);
            ds.Add(-5);
            ds.Add(-9);
            data.Datas = ds;
            datas.Add(data);

            data = new ChartTools.Series();
            //data.Color = "F1683C";
            data.Name = "昨日";
            ds = new List<double>();
            ds.Add(4);
            ds.Add(2);
            ds.Add(43);
            ds.Add(39);
            ds.Add(5);
            ds.Add(5);
            ds.Add(-5);
            ds.Add(-9);
            data.Datas = ds;
            datas.Add(data);

            ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "twolines", "showflash2");
            return msline.ToString();
        }
        public static string TwoLine2()
        {
            List<string> names = new List<string>();
            names.Add("1日");
            names.Add("2日");
            names.Add("3日");
            names.Add("4日");
            names.Add("5日");
            names.Add("6日");
            names.Add("7日");
            names.Add("8日");

            List<ChartTools.Series> datas = new List<ChartTools.Series>();
            ChartTools.Series data = new ChartTools.Series();
            //  data.Color = "1D8BD1";
            data.Name = "2010/9/5-2010/10/3";
            List<double> ds = new List<double>();
            ds.Add(10);
            ds.Add(20);
            ds.Add(23);
            ds.Add(-9);
            ds.Add(10);
            ds.Add(20);
            ds.Add(-5);
            ds.Add(-9);
            data.Datas = ds;
            datas.Add(data);

            data = new ChartTools.Series();
            //  data.Color = "F1683C";
            data.Name = "2010/10/5-2010/11/3";
            ds = new List<double>();
            ds.Add(4);
            ds.Add(2);
            ds.Add(43);
            ds.Add(39);
            ds.Add(5);
            ds.Add(5);
            ds.Add(-5);
            ds.Add(-9);
            data.Datas = ds;
            datas.Add(data);

            ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "twolines", "showflash2");
            return msline.ToString();
        }

        public static string GroupPie(int groupId, int month, int year, DB.DBManager db)
        {
            Sys.TradeHistory th = new Sys.TradeHistory();
            th = th.GetMonthLastTradingDay(year, month, db);
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();

            List<Sys.Operator> operators = new Sys.DayGroupOperators().GetGroupOperators(groupId, Convert.ToDateTime(th.YPdate + "-" + th.MPdate + "-" + th.DPdate), db);
            foreach (Sys.Operator op in operators)
            {
                ChartTools.Pie3DData data = new ChartTools.Pie3DData();
                data.Label = op.UName;
                // data.IsSelected = true;
                View.OperatorMonthSum sum = new View.OperatorMonthSum().GetOperatorMonthSum(op.Id, th.MPdate, th.YPdate, db);
                data.Value = sum.DayCount;
                datas.Add(data);
            }
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "GroupPie", "showflash", "盈利占比", 160);
            return pie3d.ToString();
        }

        public static string YearGroupPie(int groupId, int year, DB.DBManager db)
        {
            Sys.TradeHistory th = new Sys.TradeHistory();
            // th = th.GetMonthLastTradingDay(year,db);
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            th = th.GetYearLastTradingDay(year, db);
            List<Sys.Operator> operators = new Sys.DayGroupOperators().GetGroupOperators(groupId, Convert.ToDateTime(th.YPdate + "-" + th.MPdate + "-" + th.DPdate), db);
            foreach (Sys.Operator op in operators)
            {
                ChartTools.Pie3DData data = new ChartTools.Pie3DData();
                data.Label = op.UName;
                // data.IsSelected = true;
                View.OperatorYearSum sum = new View.OperatorYearSum().GetOperatorYearSum(op.Id, th.YPdate, db);
                data.Value = sum.DayCount;
                datas.Add(data);
            }
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "GroupPie", "showflash", "盈利占比", 160);
            return pie3d.ToString();
        }

        public static string GroupBar(int groupid, int tradeHistoryId, DB.DBManager db)
        {
            List<ChartTools.MSBar3DData> datas = new List<ChartTools.MSBar3DData>();
            Sys.TradeHistory th = new Sys.TradeHistory();
            th = th.GetModel(tradeHistoryId, db);
            List<Sys.Operator> operators = new Sys.DayGroupOperators().GetGroupOperators(groupid, Convert.ToDateTime(th.YPdate + "-" + th.MPdate + "-" + th.DPdate), db);

            List<View.OperatorDayChange> changes = new List<View.OperatorDayChange>();

            foreach (Sys.Operator op in operators)
            {
                View.OperatorDayChange change = new View.OperatorDayChange().GetOperatorDayChange(op.Id, tradeHistoryId, db);
                changes.Add(change);
            }

            foreach (View.OperatorDayChange change in changes)
            {
                ChartTools.MSBar3DData data = new ChartTools.MSBar3DData();
                data.SeriesName = change.Operator.UName;
                data.datas.Add(Convert.ToDecimal(change.Profit));
                data.datas.Add(Convert.ToDecimal(change.DayCount));
                data.datas.Add(Convert.ToDecimal(change.Free));
                datas.Add(data);
                data = new ChartTools.MSBar3DData();
            }
            List<string> Labels = new List<string>();
            Labels.Add("平仓盈亏");
            Labels.Add("净利润");
            Labels.Add("手续费");
            ChartTools.MSBar3D pie3d = new ChartTools.MSBar3D(Labels, datas, "GroupBar", "showflash", "盈利占比");
            return pie3d.ToString();
        }



        public static string CompanyBar(int month, int year, DB.DBManager db)
        {
            List<ChartTools.MSBar3DData> datas = new List<ChartTools.MSBar3DData>();
            List<Sys.Groups> groups = new Sys.Groups().GetGroups(db);


            foreach (Sys.Groups g in groups)
            {
                Data.Month.GroupMonthSum gms = new Data.Month.GroupMonthSum().GetGroupMonthSum(g.Id, month, year, db);

                ChartTools.MSBar3DData data = new ChartTools.MSBar3DData();
                data.SeriesName = gms.Group.GroupName;
                data.datas.Add(Convert.ToDecimal(gms.Profit));
                data.datas.Add(Convert.ToDecimal(gms.DayCount));
                data.datas.Add(Convert.ToDecimal(gms.Free));
                datas.Add(data);
                data = new ChartTools.MSBar3DData();
            }
            List<string> Labels = new List<string>();
            Labels.Add("平仓盈亏");
            Labels.Add("净利润");
            Labels.Add("手续费");
            ChartTools.MSBar3D pie3d = new ChartTools.MSBar3D(Labels, datas, "GroupBar", "showflash", "盈利占比");
            return pie3d.ToString();
        }

        public static string CompanyDayBar(int day, int month, int year, DB.DBManager db)
        {
            List<ChartTools.MSBar3DData> datas = new List<ChartTools.MSBar3DData>();
            List<Sys.Groups> groups = new Sys.Groups().GetGroups(db);


            foreach (Sys.Groups g in groups)
            {
                Data.Day.GroupDayChange gms = new Data.Day.GroupDayChange().GetGroupDayChange(g.Id, day, month, year, db);

                ChartTools.MSBar3DData data = new ChartTools.MSBar3DData();
                data.SeriesName = gms.Group.GroupName;
                data.datas.Add(Convert.ToDecimal(gms.Profit));
                data.datas.Add(Convert.ToDecimal(gms.DayCount));
                data.datas.Add(Convert.ToDecimal(gms.Free));
                datas.Add(data);
                data = new ChartTools.MSBar3DData();
            }
            List<string> Labels = new List<string>();
            Labels.Add("平仓盈亏");
            Labels.Add("净利润");
            Labels.Add("手续费");
            ChartTools.MSBar3D pie3d = new ChartTools.MSBar3D(Labels, datas, "GroupBar", "showflash", "盈利占比");
            return pie3d.ToString();
        }
        /// <summary>
        /// 交易员月对比图像(OK)
        /// </summary>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <param name="operatorid"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static string MonthDiffBar(int month, int year, int operatorid, DB.DBManager db)
        {
            List<ChartTools.Column3DData> datas = new List<ChartTools.Column3DData>();
            var query = db.OperatorMonthSun.Where(a => a.Month == month).Where(a => a.Year == year).Where(a => a.OperatorId == operatorid).ToList();
            if (query.Count() > 0)
            {
                ChartTools.Column3DData data = new ChartTools.Column3DData();
                data.Name = "平仓盈亏";
                data.Value = Convert.ToDecimal(query.First().Profit);
                datas.Add(data);
                data = new ChartTools.Column3DData();
                data.Name = "净利润";
                data.Value = Convert.ToDecimal(query.First().DayCount);
                datas.Add(data);
                data = new ChartTools.Column3DData();
                data.Name = "手续费";
                data.Value = Convert.ToDecimal(query.First().Free);
                datas.Add(data);
            }
            else
            {
                ChartTools.Column3DData data = new ChartTools.Column3DData();
                data.Name = "平仓盈亏";
                data.Value = 0;
                datas.Add(data);
                data = new ChartTools.Column3DData();
                data.Name = "净利润";
                data.Value = 0;
                datas.Add(data);
                data = new ChartTools.Column3DData();
                data.Name = "手续费";
                data.Value = 0;
                datas.Add(data);
            }

            ChartTools.Column3D pie3d = new ChartTools.Column3D("收益对比图", "", "", datas, "", "YearBar", "showflash2");
            return pie3d.ToString();
        }
        /// <summary>
        /// 交易员月对比图像(OK)
        /// </summary>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <param name="operatorid"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static string GroupDayDiffBar(int groupId, int tradeHistoryId, DB.DBManager db)
        {
            List<ChartTools.Column3DData> datas = new List<ChartTools.Column3DData>();
            Sys.TradeHistory th = new Sys.TradeHistory();
            th = th.GetModel(tradeHistoryId, db);
            List<Sys.Operator> operators = new Sys.DayGroupOperators().GetGroupOperators(groupId, Convert.ToDateTime(th.YPdate + "-" + th.MPdate + "-" + th.DPdate), db);

            //var query = db.OperatorDayChange.Where(a => a.).Where(a => a.Year == year).Where(a => a.OperatorId == operatorid).ToList();
            if (operators.Count() > 0)
            {
                double allprofit = 0f;
                double allfree = 0f;
                double alldaycount = 0f;
                foreach (Sys.Operator op in operators)
                {
                    View.OperatorDayChange change = new View.OperatorDayChange().GetOperatorDayChange(op.Id, th.Id, db);
                    allprofit += change.Profit;
                    allfree += change.Free;
                    alldaycount += change.DayCount;
                }
                ChartTools.Column3DData data = new ChartTools.Column3DData();
                data.Name = "平仓盈亏";
                data.Value = Convert.ToDecimal(allprofit);
                datas.Add(data);
                data = new ChartTools.Column3DData();
                data.Name = "净利润";
                data.Value = Convert.ToDecimal(alldaycount);
                datas.Add(data);
                data = new ChartTools.Column3DData();
                data.Name = "手续费";
                data.Value = Convert.ToDecimal(allfree);
                datas.Add(data);
            }
            else
            {
                ChartTools.Column3DData data = new ChartTools.Column3DData();
                data.Name = "平仓盈亏";
                data.Value = 0;
                datas.Add(data);
                data = new ChartTools.Column3DData();
                data.Name = "净利润";
                data.Value = 0;
                datas.Add(data);
                data = new ChartTools.Column3DData();
                data.Name = "手续费";
                data.Value = 0;
                datas.Add(data);
            }

            ChartTools.Column3D pie3d = new ChartTools.Column3D("收益对比图", "", "", datas, "", "GroupDayDiffBar", "showflash2");
            return pie3d.ToString();
        }
        /// <summary>
        /// 交易员年对比图像(OK)
        /// </summary>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <param name="operatorid"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static string YearDiffBar(int year, int operatorid, DB.DBManager db)
        {
            List<ChartTools.Column3DData> datas = new List<ChartTools.Column3DData>();
            var query = db.OperatorYearSum.Where(a => a.Year == year).Where(a => a.OperatorId == operatorid).ToList();
            if (query.Count() > 0)
            {
                ChartTools.Column3DData data = new ChartTools.Column3DData();
                data.Name = "平仓盈亏";
                data.Value = Convert.ToDecimal(query.First().Profit);
                datas.Add(data);
                data = new ChartTools.Column3DData();
                data.Name = "净利润";
                data.Value = Convert.ToDecimal(query.First().DayCount);
                datas.Add(data);
                data = new ChartTools.Column3DData();
                data.Name = "手续费";
                data.Value = Convert.ToDecimal(query.First().Free);
                datas.Add(data);
            }
            else
            {
                ChartTools.Column3DData data = new ChartTools.Column3DData();
                data.Name = "平仓盈亏";
                data.Value = 0;
                datas.Add(data);
                data = new ChartTools.Column3DData();
                data.Name = "净利润";
                data.Value = 0;
                datas.Add(data);
                data = new ChartTools.Column3DData();
                data.Name = "手续费";
                data.Value = 0;
                datas.Add(data);
            }

            ChartTools.Column3D pie3d = new ChartTools.Column3D("收益对比图", "", "", datas, "", "YearBar", "showflash2");
            return pie3d.ToString();
        }
        public static string WinAndLose(View.OperatorDayChange change)
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "盈利";
            data.IsSelected = true;
            data.Value = change.SumWin;
            //  data.Color = "df0940";
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "亏损";
            data.IsSelected = false;
            data.Value = Math.Abs(change.SumLost);
            //    data.Color = "3d8e19";
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "WinAndLose", "showflash3", "", 120);
            return pie3d.ToString();

        }


        public static string Chengjiaoliang()
        {
            List<string> names = new List<string>();
            names.Add("1");
            names.Add("2");
            names.Add("3");
            names.Add("4");
            names.Add("5");
            names.Add("6");
            names.Add("7");
            names.Add("8");
            names.Add("9");
            names.Add("10");
            names.Add("11");
            names.Add("12");
            names.Add("13");
            names.Add("14");
            names.Add("15");
            names.Add("16");
            List<ChartTools.MSColumn3DData> datas = new List<ChartTools.MSColumn3DData>();
            ChartTools.MSColumn3DData data = new ChartTools.MSColumn3DData();
            data.Name = "成交量";
            List<double> ds = new List<double>();
            ds.Add(10);
            ds.Add(20);
            ds.Add(23);
            ds.Add(-9);
            ds.Add(10);
            ds.Add(20);
            ds.Add(-5);
            ds.Add(-9);
            ds.Add(10);
            ds.Add(20);
            ds.Add(23);
            ds.Add(-9);
            ds.Add(10);
            ds.Add(20);
            ds.Add(-5);
            ds.Add(-9);
            data.Datas = ds;
            datas.Add(data);

            data = new ChartTools.MSColumn3DData();
            data.Name = "收益";
            ds = new List<double>();
            ds.Add(4);
            ds.Add(2);
            ds.Add(43);
            ds.Add(39);
            ds.Add(5);
            ds.Add(5);
            ds.Add(-5);
            ds.Add(-9);
            ds.Add(4);
            ds.Add(2);
            ds.Add(43);
            ds.Add(39);
            ds.Add(5);
            ds.Add(5);
            ds.Add(-5);
            ds.Add(-9);
            data.Datas = ds;
            datas.Add(data);

            ChartTools.MSColumn3D msline = new ChartTools.MSColumn3D(names, datas, "Chengjiaoliang", "showflash4", "");
            return msline.ToString();
        }
        public static string ThreeLine()
        {
            List<string> names = new List<string>();
            names.Add("1日");
            names.Add("2日");
            names.Add("3日");
            names.Add("4日");
            names.Add("5日");
            names.Add("6日");
            names.Add("7日");
            names.Add("8日");
            names.Add("9日");
            names.Add("10日");
            names.Add("11日");
            names.Add("12日");
            names.Add("13日");
            names.Add("14日");
            names.Add("15日");
            names.Add("16日");
            List<ChartTools.Series> datas = new List<ChartTools.Series>();
            ChartTools.Series data = new ChartTools.Series();
            //    data.Color = "1D8BD1";
            data.Name = "平仓盈亏";
            List<double> ds = new List<double>();
            ds.Add(10);
            ds.Add(20);
            ds.Add(23);
            ds.Add(-9);
            ds.Add(10);
            ds.Add(20);
            ds.Add(-5);
            ds.Add(-9);
            ds.Add(10);
            ds.Add(20);
            ds.Add(23);
            ds.Add(-9);
            ds.Add(10);
            ds.Add(20);
            ds.Add(-5);
            ds.Add(-9);
            data.Datas = ds;
            datas.Add(data);

            data = new ChartTools.Series();
            //      data.Color = "F1683C";
            data.Name = "手续费";
            ds = new List<double>();
            ds.Add(4);
            ds.Add(2);
            ds.Add(43);
            ds.Add(39);
            ds.Add(5);
            ds.Add(5);
            ds.Add(-5);
            ds.Add(-9);
            ds.Add(4);
            ds.Add(2);
            ds.Add(43);
            ds.Add(39);
            ds.Add(5);
            ds.Add(5);
            ds.Add(-5);
            ds.Add(-9);
            data.Datas = ds;
            datas.Add(data);

            data = new ChartTools.Series();
            //  data.Color = "050505";
            data.Name = "净收益";
            ds = new List<double>();
            ds.Add(4);
            ds.Add(2);
            ds.Add(23);
            ds.Add(11);
            ds.Add(15);
            ds.Add(51);
            ds.Add(-5);
            ds.Add(-91);
            ds.Add(4);
            ds.Add(2);
            ds.Add(23);
            ds.Add(11);
            ds.Add(15);
            ds.Add(51);
            ds.Add(-5);
            ds.Add(-91);
            data.Datas = ds;
            datas.Add(data);

            ChartTools.MSLine msline = new ChartTools.MSLine(names, datas, "Threelines", "showflash4");
            return msline.ToString();
        }
        public static string CompanyPie(int year, int month, DB.DBManager db)
        {
            List<Sys.Groups> groups = new Sys.Groups().GetGroups(db);
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            foreach (Sys.Groups g in groups)
            {
                ChartTools.Pie3DData data = new ChartTools.Pie3DData();
                data.Label = g.GroupName;
                Data.Month.GroupMonthSum gms = new Data.Month.GroupMonthSum().GetGroupMonthSum(g.Id, month, year, db);
                data.Value = gms.Profit;
                datas.Add(data);
            }
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "CompanyPie", "showflash", "盈利占比", 160);
            return pie3d.ToString();
        }
        public static string CompanyPie2()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "朱浩小组";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "孙俊杰小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            data.Label = "其他小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "CompanyPie", "showflash", "", 160);
            return pie3d.ToString();
        }
        public static string CompanyPie3()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "朱浩小组";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "孙俊杰小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            data.Label = "其他小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "CompanyPie2", "showflash2", "", 160);
            return pie3d.ToString();
        }
        public static string CompanyPie4()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "朱浩小组";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "孙俊杰小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            data.Label = "其他小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "CompanyPie3", "showflash3", "", 160);
            return pie3d.ToString();
        }
        public static string CompanyPie5()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "朱浩小组";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "孙俊杰小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            data.Label = "其他小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "CompanyPie4", "showflash4", "", 160);
            return pie3d.ToString();
        }
        public static string CompanyPie6()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "朱浩小组";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "孙俊杰小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            data.Label = "其他小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "CompanyPie5", "showflash5", "", 160);
            return pie3d.ToString();
        }
        public static string CompanyPie7()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "朱浩小组";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "孙俊杰小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            data.Label = "其他小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "CompanyPie6", "showflash6", "", 160);
            return pie3d.ToString();
        }
        public static string CompanyPie8()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "朱浩小组";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "孙俊杰小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            data.Label = "其他小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "CompanyPie7", "showflash7", "", 160);
            return pie3d.ToString();
        }
        public static string CompanyPie9()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "朱浩小组";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "孙俊杰小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            data.Label = "其他小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "CompanyPie8", "showflash8", "", 160);
            return pie3d.ToString();
        }
        public static string CompanyPie10()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "朱浩小组";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "孙俊杰小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            data.Label = "其他小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "CompanyPie9", "showflash9", "", 160);
            return pie3d.ToString();
        }
        public static string CompanyPie11()
        {
            List<ChartTools.Pie3DData> datas = new List<ChartTools.Pie3DData>();
            ChartTools.Pie3DData data = new ChartTools.Pie3DData();
            data.Label = "朱浩小组";
            data.IsSelected = true;
            data.Value = 948;
            datas.Add(data);
            data = new ChartTools.Pie3DData();
            data.Label = "孙俊杰小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            data.Label = "其他小组";
            data.IsSelected = false;
            data.Value = 584;
            datas.Add(data);
            ChartTools.Pie3D pie3d = new ChartTools.Pie3D(datas, "CompanyPie10", "showflash10", "", 160);
            return pie3d.ToString();
        }
    }
}






